Installing MySQL-python

On Ubuntu it is advised to use the distributions repository. So installing python-mysqldb should be straight forward:

sudo apt-get install python-mysqldb

If you actually want to use pip to install, which is as mentioned before not the suggested path but possible, please have a look at this previously asked question and answer: pip install mysql-python fails with EnvironmentError: mysql_config not found

Here is a very comprehensive guide by the developer: http://mysql-python.blogspot.no/2012/11/is-mysqldb-hard-to-install.html

To get all the prerequisites for python-mysqld to install it using pip (which you will want to do if you are using virtualenv), run this:

sudo apt-get install build-essential python-dev libmysqlclient-dev

Leave a Comment