Stupid MySQL Python with Stupid 64 bit MySQL on Stupid 64 bit Snow Leopard

So…

I’ve decided to go with MySQL for my latest product for a variety of reasons.

To build MySQL support for Python, you have to have the MySQL headers and such available.

Even though I installed from the MySQL supported binary for OS X 10.6, the MySQL-python installer couldn’t find the support files.

To get it to work, I had to edit `site.cfg` in the `MySQL-python-1.2.3c1` directory to uncomment out line 13 and edit it to read:

mysql_config = /usr/local/mysql/bin/mysql_config

The comment in the code says, above that:

# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.

Well, isn’t that special…

Then, to add insult to stupidity:

  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 13, in 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init function (init_mysql)

I found some instructions that suggested trashing the build directory, then executing the following (I broke it into separate lines):

# export ARCHFLAGS="-arch x86_64"
# python setup.py build
# sudo python setup.py install

This, however, gave me the same error on import.

So, I trashed `build`, `dist`, and `*.egg-info` and tried again.

Same shit.

So, I dug a little deeper. Of course, there’s always the suggestion that one build MySQL from source, but that just seems melodramatic.

It’s not complaining about MySQL, it’s complaining about the module not defining an init function.

I hunted down this thread that seems to be right up to yesterday so obviously I’m not the only one arguing with this:

http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/

So far, the solutions all seem to say to run Python in 32 bit mode but that just seems idiotic. I’ve got 64 bit everything and this library just doesn’t seem to have correct build instructions. I’m not going to start crippling my system in the hopes of making it limp along; that’s just stupid.

Of course, it’s after 1am and so am I right now so I think I’ll stop…for now.

4 Comments

[...] the architecture flags as before, and [...]

[...] post and others indicated it was related to the build architecture of Python and MySQL. Bah, so this is [...]

AndyFebruary 21st, 2010 at 12:46 pm

If you’re having trouble getting it installed the new version of mysql-python requires some different instructions, also if you’re using 64 or 32 bit versions of python or mysql will make a difference. There’s some information here:

http://learninglamp.wordpress.com/2010/02/21/mysqldb-python-mysql-and-os-x-a-match-made-in-satans-bum/

Leave a comment

You must be logged in to post a comment.