There was a time not so long ago when I thought that the --user flag for installing packages could be a magic bullet for consolidating packages among different Python installations.  The --user flag is available for pip, easy_install, and setup.py for Python 2.6 and later.  It installs packages in a directory local to the user and plays well with Egg installs (and all the associated .pth chicanery).

So let's say you want to install your favorite package to use it from your system Python (with no root access), CIAO Python, and perhaps CASA.  Doing multiple installs seems like a hassle, so what if you could install it to one place and have all your Pythons be able to find and load it.  Assuming these were all the same Python major version (e.g. 2.6) then this offers the hope of working.

Don't do it.

What I've found time and again is that this leads to unintended interactions and things breaking.  Here's a great one that I got after installing Sphinx in my user area (~/.local on linux) with the CIAO Python:

/proj/sot/lib/python2.6/site-packages/Chandra/__init__.py:1: UserWarning: Module pkg_resources was already imported from /home/aldcroft/.local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py, but /proj/sot/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg is being added to sys.path

I got this warning for every module import, because it turns out the Sphinx install had installed its own setuptools.  Not good.  The problems are even worse for package scripts that install to the local bin area, and often they just plain crash.

Upshot: use --prefix if you cannot write directly into the Python installation.  This unfortunately requires setting PYTHONPATH accordingly.  The next edition of Practical Python for Astronomers (coming soon) will take a much more critical view of --user installs.



    10           6