← 返回首页

python常见错误-EnvironmentError: mysql_config not found

问题描述

在安装MySQL-python包时,出错了,报了一个EnvironmentError: mysql_config not found

# pip install MySQL-python Collecting MySQL-python==1.2.5 (from -r requirements/requirements_prod.txt (line 4)) 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-bt8zYp/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-pDomq7/MySQL-python/

解决办法

1. 确认文件是否真的不存在
# find / -name mysql_config #
2. 查看提示的不存在的文件由哪个包提供
# yum whatprovides *mysql_config* Loaded plugins: fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.163.com * updates: centos.ustc.edu.cn 1:mariadb-devel-5.5.52-1.el7.i686 : Files for development of MariaDB/MySQL applications Repo : base Matched from: Filename : /usr/lib/mysql/mysql_config Filename : /usr/share/man/man1/mysql_config.1.gz Filename : /usr/bin/mysql_config 1:mariadb-devel-5.5.52-1.el7.x86_64 : Files for development of MariaDB/MySQL applications Repo : base Matched from: Filename : /usr/share/man/man1/mysql_config.1.gz Filename : /usr/bin/mysql_config Filename : /usr/lib64/mysql/mysql_config
3. 安装相应的包
# yum install mariadb-devel
4. 确认文件是否存在
# find / -name mysql_config /etc/alternatives/mysql_config /var/lib/alternatives/mysql_config /usr/bin/mysql_config /usr/lib64/mysql/mysql_config
5. 再次安装
# pip install MySQL-python Collecting MySQL-python Installing collected packages: MySQL-python Successfully installed MySQL-python-1.2.5