Search code examples
pythonmercurialosx-mountain-lionmacportseasy-install

For real, too many installations of Python on OSX Mountain Lion


I have three different Python 2.7s at:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

I use a number of packages that come from different sources. I am currently installing packages from port (MacPorts), easy_install, pip (installed by easy_install), and Mercurial. There are also some that I have to install from image or build from source. I have more control over those.

The problem is that easy_install and pip seem to be installing to one location (/Library/Frameworks/...) and MacPorts installs to another (/opt/local/Library/Frameworks/...).

What's my best action now? Delete /Library/Frameworks/.../python2.7 and move easy_install and pip to the MacPorts one at /opt/local/...? Link the two directories? Move the MacPorts installation to /Library/Frameworks/...?

How can I consolidate these Pythons? I have tried putting both site-packages locations in my path, but only certain packages are available only for one Python and not the other and others vice versa, and I need them all available at once.


Solution

  • It seems that you have control over the stuff you're building yourself. This is how I consolidate macports with pip:

    I like using Macports for all my stuff, so I just make sure that pip and easy_install build into macports' installation of python (the one in /opt/local/...).

    You can tell where pip and easy_install will install things by using:

    readlink `which pip`
    

    (those are backticks)

    If you want pip to install to the macports direcectories, use macports to install pip:

    sudo port install py-pip
    

    Then, be sure that which pip points to something like:

    askewchan@rock:~$ which pip
    /opt/local/bin/pip
    askewchan@rock:~$ readlink `which pip`
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip-2.7
    

    From the comments below (thanks @Jonathan and @Ned) you can do the same with easy_install but its port is called py-distribute:

    sudo port install py-distribute
    

    But as far as I know, you never need to use easy_install because anything that can be easy_installed can be piped better.

    Note the port descriptions:

    askewchan@rock:Tracking {master *}$ port search *easy*install*
    py-pip @1.2.1 (python, www)
        An easy_install replacement
    
    askewchan@rock:Tracking {master *}$ port search py*distribute
    py-distribute @0.6.35 (python, devel)
        Replacement for setuptools