I’ve been tearing my hair out and trying the solutions to getting Python and MySQL to play nicely with 64-bit architecture, and the solution seems to have all components installed/run as 32-bit.
My issue is that for some reason, running Python in 32-bit mode via
$ arch -i386 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
and then
import MySQLdb
gives me
import MySQLdb
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named MySQLdb
However, when I run python in 64-bit mode and trying ‘import MySQLdb’ I get the dreaded:
import MySQLdb
Traceback (most recent call last):
File “”, line 1, in
File “build/bdist.macosx-10.6-intel/egg/MySQLdb/init.py”, line 19, in
File “build/bdist.macosx-10.6-intel/egg/_mysql.py”, line 7, in
File “build/bdist.macosx-10.6-intel/egg/_mysql.py”, line 6, in bootstrap
ImportError: dlopen(/Users/me/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/me/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture
So my question is, why can’t Python find the module in 32-bit mode? the “wrong architecture” error leads me to believe that MySQL-python is installed as 32-bit, so I don’t think it’s that 32-bit Python can’t “see” the module. I have both the python and the .python-eggs path on my $PATH in .bash_profile, so what am I missing here?
Not exactly an answer, but have you tried just to
pip install MySQL-python? If you have somemysql_configin your path, it should compile just fine.– I am using a Python 2.7.2 via homebrew, a MAMP 2.0 installation, running on 10.6. with a 64bit kernel.