I\'ve been at this for some time and read many sites on the subject. suspect I have junk lying about causing this problem. But where?
This is the error when I impor
Additional note to make the problem clear:
The error message is:
ImportError: dlopen(/Users/phoebebr/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/phoebebr/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture
The mach-o, but wrong architecture error means that python and _mysql.so have different architecture(32-bit/64-bit binary). We can check it by:
file $(which python)
file /Users/phoebebr/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
And if they do not match, we should make them match. For me, my _mysql.so is 32-bit (I happened to installed the 32-bit mysql), and my python2.7 runs in 64-bit by default. I force python runs in 32-bit by:
export VERSIONER_PYTHON_PREFER_32_BIT=yes
And problem solved.
python 2.6+ can run in 64 or 32-bit mode, check How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?