Installing MySQLdb Without Python Egg Problems
When installing Django sooner or later you will come across a system that needs MySQLdb and sooner or later you will see the following error:
[Sat May 31 19:43:19 2008] [error] [client 99.165.134.196] PythonHandler django.core.handlers.modpython: ExtractionError: Can’t extract file(s) to egg cache\n\nThe following error occurred while trying to extract file(s) to the Python egg\ncache:\n\n [Errno 13] Permission denied: ‘/root/.python-eggs’\n\nThe Python egg cache directory is currently set to:\n\n /root/.python-eggs\n\nPerhaps your account does not have write access to this directory? You can\nchange the cache directory by setting the PYTHON_EGG_CACHE environment\nvariable to point to an accessible directory.\n
The fix is to set the PYTHON_EGG_CACHE environment variable before running the install. The install instructions do not make this clear and the error sounds like the path needs to be set after install. Here are the steps to avoid the above error.
- Download the tarball from SourceForge.
- $ tar zxvf [filename of MySQLdb tarball]
- $ cd [name of resulting directory]
- $ export PYTHON_EGG_CACHE=/var/cache/python-eggs
- $ mkdir /var/cache/python-eggs
- $ chmod 777 /var/cache/python-eggs
- $ python setup.py build
- $ python setup.py install
Thats it. I’ve only run into this issue on Fedora within Amazon EC2. Other platforms and versions of the MySQLdb module may work.
More from Aware Labs
- Django Generic Relations Made Easier
- Installing Django And MySQL On MacBook Air Or OS X
- Clearing Django Form Fields One By One
- UnicodeDecodeError Exception Fix On Templates
- Connecting To Oracle Directly (Without settings.py)
Aware Labs Recommends
- WordPress For Business (The Arkayne Blog)
- Installing Django with PostgreSQL on Ubuntu (Antonio Cangiano)
- Better Python package management using source and version control systems (USwaretech)
-
pkenjora
-
pkenjora
-
pkenjora
-
pkenjora
-
pkenjora
-
Tim Wyatt
-
Brian

![Recommend [AwareLabs]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)