Mac环境下为Python安装MySQLdb库时的诸多问题解决?

第一次执行
pythonsetup.pybuild
报错:
sh:mysql_config:commandnotfound
Traceback(mostrecentcalllast):
File"setup.py",line18,in
metadata,options=get_config()
File"/Users/daodao/Desktop/Mysql/setup_posix.py",line43,inget_config
libs=mysql_config("libs_r")
File"/Users/daodao/Desktop/Mysql/setup_posix.py",line25,inmysql_config
raiseEnvironmentError("%snotfound"%(mysql_config.path,))
EnvironmentError:mysql_confignotfound
然后根据网上的解决办法,修改了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"
继续执行
pythonsetup.pybuild
然后还是继续报错,但这次跟Xcode相关:
xcrun:error:activedeveloperpath("/Applications/Xcode.app/Contents/Developer")doesnotexist,usexcode-selecttochange
error:command'/usr/bin/clang'failedwithexitstatus1
网上找了半天没有找到解决的办法。我早前曾安装后删除过Xcode
————————————
网上有人说好像是因为环境需要安装gcc,Xcode里面的command_line_tools支持GGC,不管,先重新按照了下Xcode和command_line_tools,然后继续重复执行上面的操作。
pythonsetup.pyclean
pythonsetup.pybuild
sudopythonsetup.pyinstall
果然没有再报错了。但是问题还在继续,终端进入Python测试效果
importMySQLdb
果然还是不顺利。。。报错:
Traceback(mostrecentcalllast):
File"",line1,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",line19,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):Librarynotloaded:libmysqlclient.18.dylib
Referencedfrom:/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:imagenotfound
咋破。快被折腾坏了
holdtom
浏览 302回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript