Index: /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m
===================================================================
--- /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m	(revision 27634)
+++ /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m	(revision 27635)
@@ -15,31 +15,39 @@
 %      md.mesh=gmshplanet('radius',6000,'resolution',100);
 
-	%Find path to gmsh
-	paths={
-		[getenv('ISSM_EXT_DIR') '/shared/gmsh/install/bin'],...
-		[getenv('ISSM_EXT_DIR') '/static/gmsh/install/bin'],...
-		[getenv('ISSM_EXT_DIR') '/gmsh/install/bin'],...
-		[issmdir() '/externalpackages/gmsh/install/bin'],...
-		[issmdir() '/bin'],...
-		['/usr/bin']...
-	};
-	gmshpath='';
-	for i=paths
-		if exist([i{1} '/gmsh'],'file'),
-			gmshpath = i{1};
-			break;
-		end
-	end
-	if isempty(gmshpath),
-		error('gmshplanet: gmsh executable not found!');
-	end
-
-	setenv('PATH', [gmshpath ':' getenv('PATH')]);
-
-	% Get Gmsh version
+	%Get Gmsh version
 	[s,r]=system(['gmsh -info | command grep ''Version'' | sed -e ''s/Version[[:blank:]]*:[[:blank:]]//'' | cut -d ''.'' -f1']);
-	if s~=0 || contains(r, 'dyld'),
+	if contains(r, 'dyld'),
 		error(['gmshplanet: ' r]);
 	end
+	if s~=0,
+		%gmsh executable may not be on path; attempt to find it
+
+		paths={
+			[getenv('ISSM_EXT_DIR') '/shared/gmsh/install/bin'],...
+			[getenv('ISSM_EXT_DIR') '/static/gmsh/install/bin'],...
+			[getenv('ISSM_EXT_DIR') '/gmsh/install/bin'],...
+			[issmdir() '/externalpackages/gmsh/install/bin'],...
+			[issmdir() '/bin'],...
+			['/usr/bin']...
+		};
+		gmshpath='';
+		for i=paths
+			if exist([i{1} '/gmsh'],'file'),
+				gmshpath = i{1};
+				break;
+			end
+		end
+		if isempty(gmshpath),
+			error('gmshplanet: gmsh executable not found!');
+		end
+		setenv('PATH', [gmshpath ':' getenv('PATH')]);
+
+		%Get Gmsh version
+		[s,r]=system(['gmsh -info | command grep ''Version'' | sed -e ''s/Version[[:blank:]]*:[[:blank:]]//'' | cut -d ''.'' -f1']);
+		if contains(r, 'dyld'),
+			error(['gmshplanet: ' r]);
+		end
+	end
+
 	gmshmajorversion=str2num(r);
 	if ~ismember([3,4],gmshmajorversion),
Index: /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py
===================================================================
--- /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py	(revision 27634)
+++ /issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py	(revision 27635)
@@ -24,23 +24,4 @@
     """
 
-    # Find path to gmsh
-    paths = [
-        os.environ.get('ISSM_EXT_DIR') + '/shared/gmsh/install/bin',
-        os.environ.get('ISSM_EXT_DIR') + '/static/gmsh/install/bin',
-        os.environ.get('ISSM_EXT_DIR') + '/gmsh/install/bin',
-        issmdir() + '/externalpackages/gmsh/install/bin',
-        issmdir() + '/bin',
-        '/usr/bin'
-    ]
-    gmshpath = ''
-    for path in paths:
-        if exists(path + '/gmsh'):
-            gmshpath = path
-            break
-    if gmshpath == '':
-        error('gmshplanet: gmsh executable not found!')
-
-    os.environ['PATH'] = gmshpath ':' os.environ.get['PATH']
-
     # Get Gmsh version
     subproc_args = 'gmsh -info 2>&1 | command grep \'Version\' | sed -e \'s/Version[[:blank:]]*:[[:blank:]]//\' | cut -d \'.\' -f1'
@@ -49,8 +30,37 @@
     try:
         strErrs = errs.decode()
-    except AttributeError:  #this is not a byte variable, let's assume string
+    except AttributeError:  # this is not a byte variable, let's assume string
         strErrs = errs
     if strErrs != '':
-        raise Exception('gmshplanet: call to gmsh failed: {}'.format(errs))
+        # gmsh executable may not be on path; attempt to find it
+        paths = [
+            os.environ.get('ISSM_EXT_DIR') + '/shared/gmsh/install/bin',
+            os.environ.get('ISSM_EXT_DIR') + '/static/gmsh/install/bin',
+            os.environ.get('ISSM_EXT_DIR') + '/gmsh/install/bin',
+            issmdir() + '/externalpackages/gmsh/install/bin',
+            issmdir() + '/bin',
+            '/usr/bin'
+        ]
+        gmshpath = ''
+        for path in paths:
+            if exists(path + '/gmsh'):
+                gmshpath = path
+                break
+        if gmshpath == '':
+            error('gmshplanet: gmsh executable not found!')
+
+        os.environ['PATH'] = gmshpath ':' os.environ.get['PATH']
+
+        # Get Gmsh version
+        subproc_args = 'gmsh -info 2>&1 | command grep \'Version\' | sed -e \'s/Version[[:blank:]]*:[[:blank:]]//\' | cut -d \'.\' -f1'
+        subproc = subprocess.Popen(subproc_args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+        outs, errs = subproc.communicate()
+        try:
+            strErrs = errs.decode()
+        except AttributeError:  # this is not a byte variable, let's assume string
+            strErrs = errs
+        if strErrs != '':
+            raise Exception('gmshplanet: call to gmsh failed: {}'.format(errs))
+
     gmshmajorversion = int(outs)
     if gmshmajorversion not in [3, 4]:
