A MySQLdb issue on Lion

3 replies [Last post]
pharris
User offline. Last seen 6 years 3 weeks ago. Offline
Joined: 10/19/2010

First, I want to echo other folk's comments and sentiments on your book - it is a great resource and has really changed how I approach research questions and gathering data from many of the biology resources on the web.

OK - here is the problem. Like others, I'm stuck in Ch. 15 because of ImportError messages associated with MySQLdb. I followed and tried the other suggestions that have been posted in the Forums, but without any luck. Here is my recurring error message:

>>> import MySQLdb
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 19, in
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/pharris/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/pharris/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

I'm guessing this is because MySQLdb isn't Mac OSX 10.7 compatible...is this true? If not, any suggestions? If so, do you know of another solution (e.g., a comparable module on PyPi) that could be used instead of MySQLdb?

Thanks again for your efforts and help!

cdunn
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 08/15/2010
MYSQLdb with Lion

I just messed around with this a bit, and had the same experience as you. I got the above error even after I had put the following line line in my .bash_profile:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

It turns out that you need to have this line, but also have the 64 bit version of mysql installed prior to running the mysql-python setup.py script.

So, at this point try the following:

- Download and run the installer for the 64 bit version of mysql. At present, that would be the mysql-5.5.15-osx10.6-x86_64.dmg file from http://dev.mysql.com/downloads/mysql/ .

- Add the export line above to .bash_profile, if you haven't already.

- Rerun the commands for installing mysql-python. Do this in a fresh MySQL-python folder, ie delete the folder you already created and start over beginning at the tar step.

This worked on my machine, let me know if it gives any troubles on yours.

Jorge Ibarra Ca...
User offline. Last seen 6 years 6 weeks ago. Offline
Joined: 07/09/2011
MYSQLdb with Lion

Thank you so much! This works for me (using Lion), but I also needed to add the "MyConnection.commit()" line to my "mylatlon_4.py", as suggested for Pg. 277 here: http://practicalcomputing.org/feedback. I did that just before the closing statements.

pharris
User offline. Last seen 6 years 3 weeks ago. Offline
Joined: 10/19/2010
MYSQLdb with Lion

Your recommendations all worked without any problems! I completed Ch. 15 w/o any further hang-ups or errors. Thanks again for your help - I really appreciate your efforts.