Search code examples
pythonmacospippython-2.6easy-install

pip on OS X: installed 2.6 Python not recognizing modules installed with pip2.6


With Python 2.6.8 and 2.7.10 (plus anaconda installs etc.) on my Mac, I needed to install 2.6.6 32-bit (long story), so I installed it from dmg. With luck, when I then typed python2.6 in a shell, the 2.6.6 interpreter started (though only in that tab, not in others - perhaps this is significant?).

I then needed to install some modules, needing to make sure that they were got installed for this newly-in-place 2.6.6, not any other install. So I took the approach outlined here, namely:

sudo easy_install-2.6 pip

I then installed my desired module using pip2.6:

sudo pip2.6 install py2app==0.5.2

When I went to run py2app using python2.6:

python2.6 setup.py py2app

It complained that setuptools was not installed. So as before,

sudo pip2.6 install setuptools

But once again:

MacBook-Pro-de-Pyderman:projet Pyderman$ python2.6 setup.py py2app
Traceback (most recent call last):
  File "setup.py", line 98, in <module>
    mac_setup()
  File "setup.py", line 46, in mac_setup
    from setuptools import setup
ImportError: No module named setuptools

So .... pip2.6 is installing modules, just not for 2.6.6. Is there a step I am missing, in order to ensure that python 2.6.6 is the default home for modules downloaded with pip2.6? Or is pip2.6 the wrong approach here?

As requested:

MacBook-Pro-de-Pyderman:project Pyderman$ which -a python2.6    
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 
/usr/bin/python2.6 
/usr/local/bin/python2.6 

MacBook-Pro-de-Pyderman:project Pyderman$ which -a pip2.6 
/usr/local/bin/pip2.6

Note: I will eventually move to using pyenv and/or virtualenv, but for now, I'm looking to achieve this without them.


Solution

  • This should work for you, please open a new terminal for executing these commands:

    cd /tmp
    wget https://bootstrap.pypa.io/get-pip.py
    sudo /Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 get-pip.py
    

    After that both pip2.6 and python2.6 should point to your 2.6.6 interpreter.

    The command which python2.6 should print

    /Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
    

    The command which pip2.6 should print

    /Library/Frameworks/Python.framework/Versions/2.6/bin/pip2.6