Python: MySQLdb and "Library not loaded: libmysqlclient.16.dylib" Python: MySQLdb and "Library not loaded: libmysqlclient.16.dylib" python python

Python: MySQLdb and "Library not loaded: libmysqlclient.16.dylib"


Just set the DYLD_LIBRARY_PATH after running pip install or easy_install:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

Should do the job assuming your MySQL installation lives under /usr/local/mysql.


_mysql.so refers to libmysqlclient.16.dylib. That is, the shared library that serves as the bridge between Python and the MySQL client library, _mysql.so, refers to the dynamic library for the MySQL client library, and that library cannot be loaded for some reason.

Questions you need to answer:

  • Is there a libmysqlclient.16.dylib anywhere on your system? If not, you need to installthe MySQL client software.
  • If so, is the directory containing that library in your DYLD_LIBRARY_PATH setting? If not,try adding it.
  • If so, you'll have to ensure that the libmysqlclient.16.dylib file is not corrupt. Mycopy, installed in /opt/local/lib/mysql5/mysql/libmysqlclient.16.dylib, courtesy ofMacPorts, has MD5 signature c79ee91af08057dfc269ee212915801a and is 1,462,376 bytes in size. What does your copy look like?


After easy_install, I create a soft link that solved the problem

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