解决Ubuntu下pip安装mysql-python报错mysql_config not found
本文介绍在Ubuntu系统中使用pip安装mysql-python时,因缺少mysql_config命令导致EnvironmentError的解决方法。通过执行sudo apt-get install libmysqlclient-dev安装相关依赖即可修复该问题,适用于Debian系Linux发行版。
在执行安装操作时,系统提示找不到mysql_config环境变量,具体报错信息如代码片段所示。
$ pip install mysql-python
Collecting MySQL-python==1.2.5 (from -r requirement (line 16))
Downloading MySQL-python-1.2.5.zip (108kB)
100% |################################| 112kB 56kB/s
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-HVEeJz/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-HVEeJz/MySQL-python/
修复该问题的方法如下:
出现此错误的原因是系统中未安装相关的开发依赖库。
对于Ubuntu或Debian系统,
sudo apt-get install libmysqlclient-dev
以上即为解决Ubuntu系统中pip安装mysql-python包时出现错误的完整方案,希望此内容能为您提供帮助。
免责声明:本文内容仅供参考,不代表本站观点。转载或引用请注明出处。









