MySQL-python模块安装方法

By | 2019年8月5日

直接输入pip install MySQL-python  会报错,百度了一些,结果都不管用,后来试了好多次,发现以下操作可以正常使用。

先来个报错信息。

xxx@xxx-ThinkPad-E460:~$ pip install MySQL-python
Collecting mysqlclient
Downloading https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz (85kB)
100% |████████████████████████████████| 92kB 72kB/s
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File “<string>”, line 1, in <module>
File “/tmp/pip-build-qymnDO/mysqlclient/setup.py”, line 16, in <module>
metadata, options = get_config()
File “setup_posix.py”, line 51, in get_config
libs = mysql_config(“libs”)
File “setup_posix.py”, line 29, 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-qymnDO/mysqlclient/

最后解决是

sudo apt-get install libmysql++-dev

然后执行

pip install MySQL-python

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注