报错信息:
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-Lil8nB/MySQL-python/setup.py", line 17, in <module>
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
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-Lil8nB/MySQL-python/
解决方法:(注:这里只是我遇到的问题,摸索到的解决方法,并不表示可以解决所有遇到此类的错误!)
[root@sishen ~]#python -m pip install --upgrade --force pip
[root@sishen ~]#pip install setuptools==33.1.1
[root@sishen ~]#yum install -y mysql-dev python-dev libmysqlclient-dev (红色部分,依据个人情况安装)
[root@sishen ~]#pip install MySQL-python
测试
[root@sishen ~]# python
Python 2.7.14 (default, Sep 20 2017, 20:34:26)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
这就表示已经成功安装MySQL-python。