Title: Python Mac OS X MySQL problems Date: 2011-06-21 06:14 Author: eamonnfaherty Category: development Tags: mac os x, mysql, python Slug: python-mac-os-x-mysql-problems
I recently had a three hour head banging off of wall session getting Python to play nicely with MySQL.
I was getting the following error:
File “/Library/Python/2.6/site-packages/Django-1.3-py2.6.egg/django/db/backends/mysql/base.py”, line 14, in
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/eamonnfaherty/.python-eggs/MySQL\_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/\_mysql.so, 2): no suitable image found. Did find:
/Users/eamonnfaherty/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture
This was a complete mix up between 32bit and 64bit Python libraries working together with MySQL.
To fix it I put the following in my .profile file
export ARCHFLAGS=’-arch i386’
After adding this I ran a clean, build and install on the mysql-python library and everything worked! Phew!