Installing MySQL-python for Django

When doing in a virtualenv :

pip install MySQL-python

I got

EnvironmentError: mysql_config not found

To install mysql_config, as Artem Fedosov said, first install

sudo apt-get install libmysqlclient-dev

then everything works fine in virtualenv


Spent an hour looking through stackoverflow. Evntually found answer in the other question. This is what saved me:

sudo apt-get install libmysqlclient-dev

mysql_config goes with the package.


I recently had exactly this issue (just not in relation to Django). In my case I am developing on Ubuntu 12.04 using the default pip and distribute versions, which are basically a little out of date for MySQL-python.

Because you are working in an isolated virtualenv, you can safely follow the suggested instruction without affecting your Python installation.

So you can...

workon your_virtualenv #activate your virtualenv, you do use virtualenvwrapper, right?
easy_install -U distribute #update distribute on your virtualenv
pip install MySQL-python #install your package

If for some reason upgrading distribute is not an option, you could try installing an older version of MySQL-python as follows (you'd have to check this version is compatible with your version of Django):

pip install MySQL-python==x.y.z #where x.y.z is the version you want