我正在尝试设置 MySQLdb 以与 Scrapy 的 python 一起使用。我正在使用以下步骤:
安装 PIP:
sudo easy_install pip
编辑~/.profile:
nano ~/.profile
复制并粘贴以下两行
export PATH=/usr/local/mysql/bin:$PATH
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
保存并退出。之后执行以下命令
source ~/.profile
安装MySQLdb
sudo pip install MySQL-python
完成最后一步后,我收到以下错误:
usf-gold-wifi-226-5-42:documents soufin_r$ sudo pip install MySQL-python
Downloading/unpacking MySQL-python
Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
Running setup.py (path:/private/tmp/pip_build_root/MySQL-python/setup.py) egg_info for package MySQL-python
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/private/tmp/pip_build_root/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
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/private/tmp/pip_build_root/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
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /private/tmp/pip_build_root/MySQL-python
Storing debug log for failure in /Users/soufin_r/Library/Logs/pip.log
usf-gold-wifi-226-5-42:documents soufin_r$
最佳答案
EnvironmentError: mysql_config not found
先安装MySQL客户端工具和开发文件。
关于python - 尝试在 OS X 上安装 MySQLdb 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25925124/