Since I develop python programs that must run on different python versions, I have installed different versions of python on my computer.

I am using FC 13 so it came with python 2.6 pre-installed in /usr/bin/python2.6 and /usr/lib/python2.6.

I installed python 2.5 from source, and to keep things neat, I used the --prefix=/usr option, which installed python in /usr/bin/python2.5 and /usr/lib/python2.5.

Now, when I run python my prompt shows I am using version 2.5. However, I am having some issues with the install.

Package management:

Using easy_install, packages are always installed in /usr/lib/python2.6/site-packages/. I downloaded setuptools .egg for python 2.5 and tried to install it, but it gives me an error:

/usr/lib/python2.5/site-packages does NOT support .pth files

It seems that python2.5 is not in my PYTHONPATH. I thought the default install would add itself to the PYTHONPATH, but when I write echo $PYTHONPATH at promt, I just receive an empty line.


5 Answers 5


The recommended way of having multiple Python versions installed is to install each from source - they will happily coexist together. You can then use virtualenv with the appropriate interpreter to install the required dependencies (using pip or easy_install). The trick to easier installation of multiple interpreters from source is to use:

sudo make altinstall

instead of the more usual "sudo make install". This will add the version number to the executable (so you'd have python-2.5, python-2.6, python-3.2 etc) thus preventing any conflicts with the system version of Python.

  • 2
    Altinstall + virtualenv = python development nirvahna. Thanks!
    – Alex
    Commented Aug 23, 2011 at 0:11

This sounds like a perfect application for virtualenv, a very popular tool for creating isolated Python environments. This is a sample command to specify the version of Python

$ virtualenv --python=/usr/bin/python2.6 myvirtualenv
  • I don't think virtualenv is the solution in this case. See my answer. Commented Oct 19, 2012 at 16:11

Using easy_install, packages are always installed in /usr/lib/python2.6/site-packages/

That's because distutils adds shebang line to all scripts being installed. If you run easy_install script directly it gets executed with the interpreter it was installed with (according to shebang line). Which easy_install is being run depends on your PATH not PYTHONPATH. If you want to install a package in Python 2.5 instance you should run easy_install specifying Python interpreter to use:

/usr/bin/python2.5/python easy_install ...

Strictly speaking virtualenv doesn't help here as it must be created in the context of base Python which is exactly the same problem as with running easy_install. That's what --python argument of virtualenv is for. For some reason easy_install does not provide analogous argument so it must be run with specific Python interpreter as shown above.

  • It's my first answer here and I hope the first Necromancer badge as well :) Commented Oct 19, 2012 at 16:09
  • Very good explanation, thank you! Necromancer badge well earned ;)
    – Alex
    Commented Oct 24, 2012 at 15:49

I'm also using Fedora 13 and PYTHONPATH is not set.

Within python, sys.path will give you a list of the paths used for importing scripts.

I'm not familiar with how easy_install decides its destination directory but I'm sure there would be a command line argument you could give it.

Try specifying which python version to run easy_install under by preceding your command with the full path to the python you want.

Also check if easy_install is a symlink in bin to a script within one python version you have installed.


Virtualenv is definitely a godsend here.

In my setup, I have environment variable VIRTUALENV_USE_DISTRIBUTE set to 1, so that the more modern Distribute package is used instead of setuptools. I created virtual environments for the two versions of Python on my system like so:

$ virtualenv -p python2.6 py2
$ virtualenv -p python3.2 py3

I then created three aliases in .bashrc:

alias py2='source $HOME/py2/bin/activate'
alias py3='source $HOME/py3/bin/activate'
alias idle='python -m idlelib.idle'

Thus I can use py2 to switch to a default of Python 2.6 and py3 to switch to a default of Python 3.2. Entering idle will run whichever version of IDLE is appropriate for the virtual environment I am in.

Installation of packages into one of these virtual environments usually just involves a pip install command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .