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 install the 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. My copy, installed in/opt/local/lib/mysql5/mysql/libmysqlclient.16.dylib
, courtesy of MacPorts, has MD5 signaturec79ee91af08057dfc269ee212915801a
and is 1,462,376 bytes in size. What does your copy look like?