Attempting to get Python communicating with MySQL via MySQLdb on OS X resulted in the following error when I tried to import MySQLdb:
Traceback (most recent call last): File "./dbtest.py", line 3, inimport MySQLdb File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__ ImportError: dlopen(/Users/fitzsimj/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.16.dylib Referenced from: /Users/fitzsimj/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so Reason: image not found
I eventually found a solution mentioned here. I added the following line to /etc/bashrc:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
There is another solution suggested, using install_name_tool. That approach involves Ruby, which I’m not using.
EXCELLENT!!! That was the last piece of the puzzle for me to get my database to begin importing!!! Thank you very much!
Thanks for the tip! That was the last piece of the puzzle for me too. I’m running Mac OS 10.7.x on a 64-bit MacBook Pro and built MySQL-python-1.2.3 from source. (I also had to set ARCHFLAGS=’-arch x86_64′)
Thank you so much. I ran into this trying to setup a Django environment on a OS X Lion Preview build.
Thanks so much! Just what I needed :^)
You’re my hero!
Thanks! Exactly what I needed, but how on earth did you figure this out?
I love you. I mean it. Thanks.