Install MySQL-python on Ubuntu
1. First, you need to determine whether the Ubuntu update source can be used. The source of Ubuntu 14.04 tested in this article has not been tried in earlier versions of Ubuntu. After all, labor is not a tester.
For security, cp/etc/apt/source. list/etc/apt/source. list. bak
The following is the source of Ubuntu 14.04. (find the source of other versions by yourself) write the following content to/etc/apt/source. list.
Deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
Deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
Deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
Deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
Deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
The deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
Deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
Deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
The deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
The deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
2. sudo apt-get update
3. sudo apt-get install mysql-python
An error is reported:
Sh: mysql_config: not found
Traceback (most recent call last ):
File "setup. py", line 15, in <module>
Metadata, options = get_config ()
File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
Libs = mysql_config ("libs_r ")
File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
Raise EnvironmentError ("% s not found" % (mysql_config.path ,))
EnvironmentError: mysql_config not found
4. The specific cause is that the mysql_config file cannot be found under/usr/bin.
The solution for online query is generally that you do not have libmysqld-dev or libmysqlclient-dev, but you can find that all of them exist.
5. First, an important python-dev is generally not installed, so sudo apt-get install python-dev is required.
Continue to install mysql-python.
6. reinstall libmysqlclient-dev,
The miracle finally appeared: