安裝MySQL-python時報錯`EnvironmentError: mysql_config not found`的解決辦法
阿新 • • 發佈:2018-12-12
在ubuntul
下的linux
系統下安裝MySQL-python
時,報錯EnvironmentError: mysql_config not found
,錯誤程式碼顯示如下:
(django_e_shop) [email protected]:~/django_e_shop$ pip install MySQL-python==1.2.5
Collecting MySQL-python==1.2.5
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2 .5.zip
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-install-PuWQRJ/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-install-PuWQRJ/MySQL-python/
查詢原因是系統未安裝:libmysqlclient-dev
,通過如下命令安裝
sudo apt-get install libmysqlclient-dev
然後找到Linux下的mysql_config
檔案的路徑,執行如下兩條命令:
sudo updatedb
locate mysql_config
其中mysql_config
檔案的預設路徑是在/usr/bin/mysql_config
。
執行完成後再次使用pip install mysql-python
命令安裝後就可以正常使用了。