0

My Mac came with Python 2.6.9 and 2.7.6 (the default 'Python') installed. I needed several modules from the SciPy stack and installed them using MacPorts:

py27-numpy py27-scipy py27-matplotlib py27-pandas

Now for whatever reason this installed another Python version alongside the ones I already had, Python 2.7.8. All the packages only work with this one. When I start a new project in XCode and point it to this new instance, /usr/bin/python2.7, nothing works and I get

'/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '

I can make XCode work with the 2.7.6 version, /usr/bin/python, but then none of the packages I need are available.

Is there any way to either make XCode work with this other python instance, or to remove the 2.7.6 entirely and replace the default python with the new one?

user28400
  • 187
  • 1
  • 8

1 Answers1

0

The correct path to the MacPorts python is /opt/local/bin/python2.7. By using the MacPorts version of Python, you are ensured that all of the necessary dependencies are found. I was able to follow these instructions and get everything to work. The only catch was in step 16 I had to manually enter the path because /opt was not visible.

Alternatively, you could try adding the MacPorts library path to your PYTHONPATH. Just add

export PYTHONPATH=$PYTHONPATH:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/

to your .bash_profile. I will warn you that when I tried mixing Pythons in the past I frequently got errors relating to trying to import wrong module.

Community
  • 1
  • 1
Keith Prussing
  • 583
  • 6
  • 17