MySQL Library not loaded: libmysqlclient.18.dylib

Although I had MySQL community edition installed on my Mac OSX , I recently had the following error while running some python installation script which uses mysql as a backend. The error was:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so

Solution:
1. Locate your MySQL installation & create symlink in /usr/lib for that. That’s it 🙂

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

1 Comment

Jeffrey LangFebruary 23rd, 2016 at 8:04 pm

Very nice. This worked for me. Thanks!

Leave a comment

Your comment

CAPTCHA
*