Installing Python eggs for multiple users
I recently needed to update my python-psycopg2 package to a version that wasn't available in the Debian or Backports repositories, so I decided to use Python's ez_install command. In short, ez_install installs Python eggs, which are equivalent to Ruby's gems and are meant to be a cross-distro library installation system. However, the egg couldn't be used by other UNIX users.
By default, ez_install downloads the egg and saves it as is. When the library is imported, it is extracted to the folder in PYTHON_EGG_CACHE,
which happened to be /home/martin/.python-eggs for me. This was all
good and well until I started my fastcgi Django app as the www-data
user,which does not have write permissions to /home/martin. There seemed to be 3 possible fixes:
- Give www-data write access on /home/martin/.python-eggs
- Set the PYTHON_EGG_CACHE variable
- Extract the egg
I chose the latter, and as many sites report, this can be done on Debian by appending to (or creating if it isn't there), the file /usr/lib/python2.4/distutils/distutils.cfg . The path will be different on other distributions and Python versions. It should contain:
[easy_install]
zip_ok = 0
Now delete the egg from /usr/lib/python/2.4/site-packages, and issue the ex_install command again. This time it will download the egg, and extract it to a folder, so no cache is needed, and all users will be able to import it.




comments
Thanks for this post!
I couldn't figure out how to force distutils to extract eggs. With easy_install you can use the '-Z' option but not using the 'setup.py install' approach
Again, thanks!