从sourceforge下载MySQLdb之后,我运行setup.py来安装它。现在当我尝试导入“MySQLdb”时,我收到以下错误:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so
Reason: image not found
我是python的新手,所以我不确定这意味着什么。任何人都可以帮我弄清楚如何缓解这个错误?谢谢!!!
答案 0 :(得分:2)
您需要mysql客户端库来构建MySQLdb
。我知道在Mac OS X中安装它的最简单方法是获取homebrew,然后安装mysql
:
brew install mysql
额外奖励 - 您也可以使用brew轻松安装python 3。