Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

For some reason, when I start GRASS on my Mac it says that it has found Python 2.6.7. However, /usr/bin/python version is 2.7.2 and I can't find a lower version anywhere on my system. Potentially relevant system info follows:

Mac OS X 10.8.3

GRASS version 6.4.2 (2012) and all required frameworks installed with binaries from http://www.kyngchaos.com/software/grass in the past few days, so everything should be as up-to-date as I know how to make it.

I suppose this is really a two-part question.

  1. How can I tell where GRASS is finding Python?
  2. How can I tell GRASS where it should be finding Python?
share|improve this question

2 Answers 2

up vote 4 down vote accepted

1: How can I tell where GRASS is finding Python?

if you want to find the path of the executable used by GRASS GIS, go to the Python console of the GRASS GIS Layer Manager

import sys
print sys.executable
# or
import os
os.__file__

2 How can I tell GRASS where it should be finding Python?

open the file /Applications/GRASS-6.4.app/Contents/MacOS/grass.sh, which is the script that runs GRASS GIS, and look for (lines 198 - 255)

py=""
# did user set GRASS_PYTHON already? check it (must have pythonw)
if [ "$GRASS_PYTHON" ] ; then
....

but proceed with caution because the version of William Kyngesburye use some specific libraries in /Applications/GRASS-6.4.app/Contents/MacOS/etc/python/ like wxPython for the GUI (specific to a Python version)

"One of the problems with doing this kind of stuff on a Mac is that any version of Python you install is going to conflict with the default version of Python that comes with OS X."

Not at all, just adjust the paths in usr/bin as do the Python frameworks of Python.org or Enthought, for example, or the paths specified in .bash_profile like the versions of Homebrew (in /usr/local/bin) or Macports (in /opt/bin). I have several versions of Python installed and I go from one to another without problem.

The problem are the applications that requires a specific version of Python like the version of QGIS of Kyng Chaos. In this case, there are symbolic links (like Python2.7 and Python2.7-config, for example) that you can adjust.

Another solution is to compile yourself GRASS GIS following the indications of Kyng Chaos (long time but not difficult) or use the GRASS GIS versions of Homebrew (which use the Homebrew version of Python) or MacPorts (which use the MacPorts version of Python)

share|improve this answer
    
Thank your for such a thorough and thoughtful answer. I might recompile GRASS myself after the deadline I'm currently working on has passed. –  Gregory Mar 23 '13 at 13:11

One of the problems with doing this kind of stuff on a Mac is that any version of Python you install is going to conflict with the default version of Python that comes with OS X. The user's inability to easily interact with the system packages belonging to the BSD subsystem is really holding back OS X as a serious development platform.

I found this link to another user's similar problem from an older release, which you may find valuable. Best of luck in hacking this out.

http://superuser.com/questions/304220/how-can-i-update-the-default-python-installation-fix-my-path-on-mac-os-x-10-6-7

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.