I downloaded and followed the install instructions for MySQL 5.5.8 (http://dev.mysql.com/downloads/mysql/) and for the MySQLdb python plugin. (http://sourceforge.net/projects/mysql-python/)
When I attempt to import MySQLdb to a python terminal, I get the below error:
Safira:~ yanigisawa$ python --version
Python 2.6.1
Safira:~ yanigisawa$ python -c "import MySQLdb"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/yanigisawa/.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/yanigisawa/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Reason: image not found
Safira:~ yanigisawa$
I found question 4559699 on stack overflow, and followed the instructions there:
Safira:~ yanigisawa$ echo $DYLD_LIBRARY_PATH
/usr/local/mysql/lib
Safira:~ yanigisawa$ ls -l /usr/local/mysql/lib
total 363224
-rwxr-xr-x 1 root wheel 3787328 Jan 18 19:41 libmysqlclient.16.dylib
-rw-r--r-- 1 root wheel 10035336 Dec 3 13:26 libmysqlclient.a
lrwxr-xr-x 1 root wheel 23 Jan 14 22:01 libmysqlclient.dylib -> libmysqlclient.16.dylib
lrwxr-xr-x 1 root wheel 20 Jan 14 22:01 libmysqlclient_r.16.dylib -> libmysqlclient.dylib
lrwxr-xr-x 1 root wheel 16 Jan 14 22:01 libmysqlclient_r.a -> libmysqlclient.a
lrwxr-xr-x 1 root wheel 20 Jan 14 22:01 libmysqlclient_r.dylib -> libmysqlclient.dylib
-rw-r--r-- 1 root wheel 88033760 Dec 3 13:22 libmysqld-debug.a
-rw-r--r-- 1 root wheel 84075304 Dec 3 13:26 libmysqld.a
-rw-r--r-- 1 root wheel 8472 Dec 3 13:26 libmysqlservices.a
drwxr-xr-x 13 root wheel 442 Dec 3 13:53 plugin
Safira:~ yanigisawa$ md5 /usr/local/mysql/lib/libmysqlclient.16.dylib
MD5 (/usr/local/mysql/lib/libmysqlclient.16.dylib) = b8a78a93183720021b9dbe9ddad57111
Safira:~ yanigisawa$
And after cleaning all of the python egg files, and rebuilding, I still got the same error. Then I found bug 59006 (http://bugs.mysql.com/bug.php?id=59006) in MySQL 5.5.8 affecting Mac 10.6. I tried the work-around listed there, cleaned eggs and rebuilt, and I'm still getting this error.
Is there another work-around for this problem specific to python? Am I missing something else?
EDIT: Adding output from otool commands:
Safira:~ yanigisawa$ otool -L /Users/yanigisawa/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
/Users/yanigisawa/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so:
libmysqlclient.16.dylib (compatibility version 16.0.0, current version 16.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
Safira:~ yanigisawa$ otool -DX /usr/local/mysql/lib/libmysqlclient.16.dylib
/usr/local/mysql/lib/libmysqlclient.16.dylib
Safira:~ yanigisawa$
In my case, I solved by adding a couple of symbolic links as in http://ageekstory.blogspot.com/2011/04/installing-massive-coupon-on-mac-os-10.html
as following:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With