This article describes how to install mysql-python in python. Share it with everyone for your reference, the details are as follows:
Operations under ubuntu system
First installed the pip tool
sudo apt-get install python-pip
Then use
sudo pip install mysql-python
Install third-party libraries. But an error is reported at this time
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
The reason is that: libmysqlclient-dev
is not installedsudo apt-get install libmysqlclient-dev
Continue the installation and find that an error is still reported
mysql.c:29:20: fatal error: Python.h: There is no such file or directory, and the Python header file cannot be found. Does wheezy not install the python development package by default?
sudo dpkg -l | grep python-dev
Sure enough, it doesn’t exist, you really need to install it:
sudo apt-get install python-dev
MySQL-python can be compiled and passed.
Readers who are interested in more Python-related content can check out the special topics on this site: "Summary of Python Image Operation Skills", "Python Data Structure and Algorithm Tutorial", "Python Socket Programming Skills Summary", "Python Function Using Skills Summary" ", "Python String Operation Skills Summary", "Python Introduction and Advanced Classic Tutorial" and "Python File and Directory Operation Skills Summary"
I hope this article will be helpful to everyone in Python programming.