Multiple python installations - setting path variable
Question: I have several python installations on my system, in /usr/lib/ I have
python2.7, python 3, python3.2. I am trying to upgrade my version of scipy
from .9. When I do a

    
    
    sudo pip install --upgrade scipy
    

It doesn't work saying that it's already done in
/usr/local/lib/python3.2/dist-packages

When I import it in ipython, however, it finds the old version of Scipy:

    
    
    /usr/lib/python2.7/dist-packages/scipy/__init__.pyc
    

How do I tell python to load the 3.2 version of scipy and not the 2.7? I
believe this has something to do with the PYTHONPATH variable, but I'm not
sure which one to change.

James


Answer: > How do I tell python to load the 3.2 version of scipy and not the 2.7

Every python version manages its own set of installed modules. The idea is to
invoke the `pip` executable that belongs to the right python version.

From what you described it seems that you have installed the ipython module in
your `python2.7` interpreter, but your pip executable belongs to the
`python3.2` interpreter.

The easiest way to execute `python2.7`'s `pip` is:

    
    
    sudo ipython -m pip install --upgrade scipy
    

However this installs scipy as root into your system files and thus usually
interferes with versions installed by package managers.

An arguably better way is to install packages in your user's home directory.

    
    
    ipython -m pip install --upgrade scipy --user
    

As pointed out in the comments, probably the best way is to get familiar with
`virtualenv`.

I myself find `anaconda` particularly appealing, since it comes with a clean
way of installing and managing multiple python interpreters with a focus on
scientific packages across many platforms.

