为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

holdtom 2019-04-09 20:23:27
第一次执行pythonsetup.pybuild报错:sh:mysql_config:commandnotfoundTraceback(mostrecentcalllast):File"setup.py",line18,inmetadata,options=get_config()File"/Users/daodao/Desktop/Mysql/setup_posix.py",line43,inget_configlibs=mysql_config("libs_r")File"/Users/daodao/Desktop/Mysql/setup_posix.py",line25,inmysql_configraiseEnvironmentError("%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-selecttochangeerror:command'/usr/bin/clang'failedwithexitstatus1网上找了半天没有找到解决的办法。我早前曾安装后删除过Xcode————————————网上有人说好像是因为环境需要安装gcc,Xcode里面的command_line_tools支持GGC,不管,先重新按照了下Xcode和command_line_tools,然后继续重复执行上面的操作。pythonsetup.pycleanpythonsetup.pybuildsudopythonsetup.pyinstall果然没有再报错了。但是问题还在继续,终端进入Python测试效果importMySQLdb果然还是不顺利。。。报错:Traceback(mostrecentcalllast):File"",line1,inFile"/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,inimport_mysqlImportError: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.dylibReferencedfrom:/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.soReason:imagenotfound咋破。快被折腾坏了
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 301 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信