1

I think I installed MySQL correctly. Almost positive, except for the fact that it isn't working

$ python
>>> import MySQLdb

returns

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

Does anyone have any ideas on how to fix this? THanks

IdeoREX
  • 1,455
  • 5
  • 22
  • 39

2 Answers2

2

create a symbolic link to the library

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

or add this path to your profile

export DYLD_LIBRARY_PATH=/usr/local/mysql-5.5.15-osx10.6-x86/lib/:$DYLD_LIBRARY_PATH
Stefan
  • 2,961
  • 1
  • 22
  • 34
1

I suppose this could be a duplicated question. You can find the way to install or link the library file in this post Python mysqldb: Library not loaded: libmysqlclient.18.dylib

Community
  • 1
  • 1
seanxiaoxiao
  • 1,282
  • 2
  • 11
  • 23