我在的环境是ubuntu14.04
在用sudo pip install Mysql-python
一下是报错信息:
Downloading/unpacking MySQL-python
Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
Running setup.py (path:/tmp/pip_build_root/MySQL-python/setup.py) egg_info for package MySQL-python
sh: 1: mysql_config: not found
Traceback (most recent call last):
File “”, line 17, in
File “/tmp/pip_build_root/MySQL-python/setup.py”, line 17, in
metadata, options = get_config()
File “setup_posix.py”, line 43, in get_config
libs = mysql_config(“libs_r”)
File “setup_posix.py”, line 25, in mysql_config
raise EnvironmentError(“%s not found” % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File “”, line 17, in
File “/tmp/pip_build_root/MySQL-python/setup.py”, line 17, in
metadata, options = get_config()
File “setup_posix.py”, line 43, in get_config
libs = mysql_config("libs_r")
File “setup_posix.py”, line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Cleaning up…
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/MySQL-python
Storing debug log for failure in /home/tony/.pip/pip.log
我看了这个EnvironmentError: mysql_config not found
sudo apt-get install libmysqlclient-dev
解决。
但是我又出现了没有Python.h目录或文件。
解决方法是安装python-dev,这是Python的头文件和静态库包:
sudo apt-get install python-dev