cached eggs

I Ran into a snafu when installing the mysql_python egg from pypi. I believe this issue relates to any egg that remains packed after install.

What happens is that a cache directory is created under the user that runs the install. Typically root, or some other privileged user that can write to Python’s site-packages dir. This cache dir, is thus inaccessible to the web server’s unprivileged account: consequently code running under mod_python, for example, cannotĀ  access the cache dir and hence the library.

One option is to create a system wide env variable, PYTHON_EGG_CACHE, and point it to some accessible directory. I believe easy_install respects this and will use it to create the cache location for the library or app that is being downloaded.

I found an easier solution. Use easy_install with the forced unpacking option to write the unpacked library into site-packages. This means the code is visible to all Python users without the need of cache directories or env. variables. (easy_install -Z yourpackage).

If you need to delete existing eggs so you can retry the install as suggested, then you need to remove the offending egg from site-packags and also from the .pth file containing a reference to it–also in site-packages.

This entry was posted in Python. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *