Installing MySQL-python
Solution 1:
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
Solution 2:
You have 2 options, as described bellow:
Distribution package like Glaslos suggested:
# sudo apt-get install python-mysqldb
In this case you can't use virtualenv no-site-packages (default option) but must use:
# virtualenv --system-site-packages myenv
Use clean virtualenv and build your own python-mysql package.
First create virtualenv:
# virtualenv myvirtualenv
# source myvirtualenv/bin/activate
Then install build dependencies:
# sudo apt-get build-dep python-mysqldb
Now you can install python-mysql
# pip install mysql-python
NOTE Ubuntu package is python-mysql*db* , python pypi package is python-mysql (without db)
Solution 3:
yum install mysql-devel
It worked for me.
Solution 4:
Reread the error message. It says:
sh: mysql_config: not found
If you are on Ubuntu Natty, mysql_config
belongs to package libmysqlclient-dev