licess 发表于 2011-5-5 14:14:18

MySQLdb/mysql-python安装时EnvironmentError: mysql_config not found

root@vpser:~# cd MySQL-python-1.2.3
root@vpser:~/MySQL-python-1.2.3# python setup.py install
sh: mysql_config: not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
    metadata, options = get_config()
File "/root/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
File "/root/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
首先查找mysql_config的位置,使用find / -name mysql_config ,比如我的在/usr/local/mysql/bin/mysql_config


修改setup_posix.py文件,在26行:
mysql_config.path = "mysql_config" 修改为:
mysql_config.path = "/usr/local/mysql/bin/mysql_config"

修改完成后保存,再执行


python setup.py build
python setup.py install


安装完成
页: [1]
查看完整版本: MySQLdb/mysql-python安装时EnvironmentError: mysql_config not found