[英]Error with MySQLdb on OS X El Capitan
I tried importing the MySQLdb within iPython and received the following error. 我尝试在iPython中导入MySQLdb并收到以下错误。
ImportError Traceback (most recent call last)
<ipython-input-4-f5538763dbdb> in <module>()
----> 1 import MySQLdb as mdb
2 import sys
/Users/user1/anaconda/lib/python2.7/site-packages/MySQLdb/__init__.py in <module>()
17 from MySQLdb.release import __version__, version_info, __author__
18
---> 19 import _mysql
20
21 if version_info != _mysql.version_info:
ImportError: dlopen(/Users/user1/anaconda/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/user1/anaconda/lib/python2.7/site-packages/_mysql.so
Reason: image not found
I found a few posts on Stackoverflow of a similar nature, where it was suggested that the System Integrity Protection should be disabled, which I have now. 我在Stackoverflow上找到了几条类似的帖子,建议我禁用系统完整性保护。
I also edited my bashprofile as suggested for OSX El Capitan in this post, Python mysqldb: Library not loaded: libmysqlclient.18.dylib but I still haven't been able to overcome this issue. 我还按照OSX El Capitan在本文中建议的方式编辑了bashprofile,即Python mysqldb:未加载库:libmysqlclient.18.dylib,但我仍然无法克服此问题。
A little more information incase it helps diagnose the issue: 更多信息,以帮助诊断问题:
Where am I going wrong? 我要去哪里错了?
After some research, I figured that the issue might have been due to OpenSSL, and permissions related to this in El Capitan. 经过研究,我发现问题可能是由于OpenSSL,以及El Capitan中与此相关的权限所致。 I found two resources which hinted at similar solutions:
我发现了两个资源,它们暗示了类似的解决方案:
So here it is: 所以这里是:
brew install --upgrade openssl
brew unlink openssl && brew link openssl --force
你可以试试:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
I had the same problem and tried a few things including the brew install, unlink, link solution without any luck. 我遇到了同样的问题,尝试了一些事情,包括brew安装,取消链接,没有任何运气的链接解决方案。 For OS X 10.12.3 running Python 2.7.12, Anaconda 2.3.0 the following worked for me.
对于运行Python 2.7.12,Anaconda 2.3.0的OS X 10.12.3,以下代码对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.