第一次执行
python setup.py build
报错:
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 18, in
metadata, options = get_config()
File "/Users/daodao/Desktop/Mysql/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/Users/daodao/Desktop/Mysql/setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
然后根据网上的解决办法,修改了setup_posix.py中
mysql_config.path = "mysql_config"
修改为我本机的mysql_config配置路径:
mysql_config.path = "/usr/local/mysql-5.6.14-osx10.7-x86_64/bin/mysql_config"
继续执行
python setup.py build
然后还是继续报错,但这次跟Xcode相关:
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist, use xcode-select to change
error: command '/usr/bin/clang' failed with exit status 1
网上找了半天没有找到解决的办法。我早前曾安装后删除过Xcode
————————————
网上有人说好像是因为环境需要安装gcc,Xcode里面的command_line_tools 支持GGC,不管,先重新按照了下Xcode和command_line_tools,然后继续重复执行上面的操作。
python setup.py clean
python setup.py build
sudo python setup.py install
果然没有再报错了。但是问题还在继续,终端进入Python测试效果
import MySQLdb
果然还是不顺利。。。报错:
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.6-intel.egg/MySQLdb/__init__.py", line 19, in
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.6-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.6-intel.egg/_mysql.so
Reason: image not found
咋破。快被折腾坏了