Saturday, June 13, 2009

Python easy_install, really

Python's easy_install, at least under Ubuntu, is neither easy, nor does it install stuff if you're not root.

Here's the shortcut:
- make your local packages directory. This means you can easily zap all your "I'm playing around with it" libraries and apps without damaging the system.
- tell Python (and easy_install) to search it
- also, tell easy_install to install packages into it

$ mkdir -p $HOME/local/lib/python2.6/site-packages
$ export PYTHONPATH=$HOME/local/lib/python2.6/site-packages
$ easy_install-2.6 -d $HOME/local/lib/python2.6/site-packages pyevolve


If the automatic network search doesn't work, then manually download the Egg and try again:

$ easy_install-2.6 -d $HOME/local/lib/python2.6/site-packages Desktop/Pyevolve-0.5-py2.6.egg

Then test it:
$ python -c 'import pyevolve; print pyevolve.__version__'
0.5


Note you'll have to add the PYTHONPATH into your ~/.bashrc, else you'll get errors like this:
$  (env -i !!)
(env -i python -c 'import pyevolve')
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named pyevolve

3 comments:

  1. I would also recommend taking a look at http://peak.telecommunity.com/DevCenter/EasyInstall#custom-installation-locations .

    The methods described include: Administrator Installation, Mac OS X "User" Installation, Creating a "Virtual" Python and "Traditional" PYTHONPATH-based Installation.

    ReplyDelete
  2. no, i think thebest solution is to use virtualenv

    ReplyDelete
  3. I've had moderate luck with Buildout. It downloads and installs eggs for you, handles dependencies, makes apps with custom sys.path, and doesn't conflict with your other tools.

    ReplyDelete