[英]Python ImportError with MySQLdb on Mac OS X (El Capitan)
I have installed MySQLdb on El Capitan using:我已经使用以下方法在 El Capitan 上安装了 MySQLdb:
brew install mysql
pip install MySQL-python
When I try python -c "import MySQLdb"
I get the following error:当我尝试
python -c "import MySQLdb"
,出现以下错误:
File "<string>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(./_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/<user>/anaconda/lib/python2.7/site-packages/_mysql.so
Reason: no suitable image found. Did find:
/usr/local/bin/mysql/lib/libssl.1.0.0.dylib: stat() failed with errno=20
Found some related posts but still did not figure out how to fix this.找到了一些相关的帖子,但仍然没有弄清楚如何解决这个问题。 Any help is much appreciated.
任何帮助深表感谢。
EDIT: If I decide to revert step 1 ( brew uninstall mysql
) because SQLite (sqlite3) comes pre-installed with El Capitan, I get the following error message:编辑:如果我决定恢复第 1 步(
brew uninstall mysql
),因为 SQLite (sqlite3) 预装了 El Capitan,我会收到以下错误消息:
File "<string>", line 1, in <module>
File "/Users/<user>/anaconda/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Users/<user>/anaconda/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
Referenced from: /Users/<user>/anaconda/lib/python2.7/site-packages/_mysql.so
Reason: image not found
What am I missing?我错过了什么? Are the two error messages related?
这两个错误消息是否相关?
I got an error like this after, I assume, homebrew updated mysql.在我假设自制软件更新了 mysql 之后,我遇到了这样的错误。 By running
pip uninstall mysqlclient && pip install mysqlclient
I got things working again without having to set DYLD_LIBRARY_PATH
.通过运行
pip uninstall mysqlclient && pip install mysqlclient
我无需设置DYLD_LIBRARY_PATH
重新开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.