centos下pip安裝mysql_python報錯mysql_config not found
阿新 • • 發佈:2018-11-10
1.安裝mysql_python時,出現如下錯誤:
Collecting mysql-python (from -r pip_requirements.txt (line 8)) Using cached https://pypi.doubanio.com/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/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-6ne7nk/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-6ne7nk/mysql-python/
2.解決辦法
1)通過yum安裝mysql-devel
# yum install -y mysql-devel
2)如果已經裝過mysql(如通過rpm包安裝),出現此錯誤,可以通過找到mysql_config位置,然後通過新增環境變數的方式解決
#找到mysql_config位置
# find / -name mysql_config
# 例如
#新增環境變數:
# echo "export PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profie # source /etc/profile
3)手工安裝mysql_python,在setup_posix.py內找到mysql_config.path,修改mysql_config.path=/usr/local/mysql/bin/mysql_config(你的mysql安裝路徑/bin/mysql_config)