mac os 上安装mysqldb,EnvironmentError: mysql_config not found

首先,下载MySQL-python:https://pypi.python.org/pypi/MySQL-python/1.2.5

解压,运行setup.py:
python setup.py install
报错:
sh: mysql_config: command not found
Traceback (most recent call last):
File “setup.py”, line 15, in <module>
metadata, options = get_config()
File “/Users/***/Downloads/MySQL-python-1.2.3/setup_posix.py”, line 43, in get_config
libs = mysql_config(“libs_r”)
File “/Users/***/Downloads/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
发现要修改site.cfg,在当前文件夹里找到该文件并修改去掉注释:
mysql_config = /usr/local/mysql/bin/mysql_config
让mysql_config指向mysql在mac os中的安装位置。
之后再用高权限运行
sudo python setup.py install
不再报错即运行成功。
注:如果依然有问题,那你首先需要去安装mac系统下的MySQL。
找到.dmg下载并安装,再重复上面的步骤。