2013-07-15 59 views
1

我想我正確安裝了MySQL。幾乎可以肯定,除了一個事實,即它不工作import MySQLdb ImportError

$ 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 

有沒有人對如何解決這一問題的任何想法? THanks

回答

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