How to use MySQLdb with Python and Django in OSX 10.6?

I had the same error and pip install MySQL-python solved it for me.

Alternate installs:

  • If you don't have pip, easy_install MySQL-python should work.
  • If your python is managed by a packaging system, you might have to use that system (e.g. sudo apt-get install ...)

Below, Soli notes that if you receive the following error:

EnvironmentError: mysql_config not found

... then you have a further system dependency issue. Solving this will vary from system to system, but for Debian-derived systems:

sudo apt-get install python-mysqldb


Adding to other answers, the following helped me finish the installation mysql-python:

virtualenv, mysql-python, pip: anyone know how?

On Ubuntu...

apt-get install libmysqlclient-dev
apt-get install python-dev
pip install mysql-python

Don't forget to add 'sudo' to the beginning of commands if you don't have the proper permissions.


Try this the commands below. They work for me:

brew install mysql-connector-c 
pip install MySQL-python

Running Ubuntu, I had to do:

sudo apt-get install python-mysqldb