Search code examples
pythonmacososx-snow-leopardmacports

MacPorts on Snow Leopard: Python install seems to succeed but doesn't install a non-system Python


I've installed Python via MacPorts. According to this question, the files in /opt/local/bin should run the "correct" Python version. However, all those files are symlinks to:

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/ 

Running them directly from that folder (using no symlinks) runs an Apple build of Python!

Python 2.6.6 (r266:84292, Jan  6 2011, 13:25:25) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

For comparison, running /usr/bin/python shows a slightly different version:

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

They're both Apple builds! How do I install the correct version?


Solution

  • I think it is running the build you want.

    macports install every thing in /opt/local. So /opt/local/bin/python is a macport distribution.

    /usr/bin/python is pre-install python distribution that comes with mac os x.

    The following line, is an information about gcc build which is used for building macport python distribution.

    [GCC 4.2.1 (Apple Inc. build 5664)]

    If you have multiple versions of macport python installed, you can select the version using python-select

    sudo port install python-select sudo
    python-select python26
    

    Also to ensure that you use macport python you could add the following to the PATH

    export PATH=/opt/local/bin:$PATH