1

我想我正确安装了 MySQL。几乎是积极的,除了它不起作用的事实

$ python
>>> import MySQLdb

返回

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: dlopen(/Users/msmith/Documents/dj/mysite/venv/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Users/msmith/Documents/dj/mysite/venv/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so
  Reason: image not found

有没有人对如何解决这个问题有任何想法?谢谢

4

2 回答 2

2

创建到库的符号链接

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

或将此路径添加到您的个人资料

export DYLD_LIBRARY_PATH=/usr/local/mysql-5.5.15-osx10.6-x86/lib/:$DYLD_LIBRARY_PATH
于 2013-07-15T17:57:58.287 回答
1

我想这可能是一个重复的问题。您可以在这篇文章Python mysqldb: Library not loaded: libmysqlclient.18.dylib中找到安装或链接库文件的方法

于 2013-07-15T17:57:55.893 回答