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
Very nice. This worked for me. Thanks!