Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can't seem to get mysql-python to work on Snow Leopard for the life of me.

Currently using the default version of python that ships with Snow Leopard (python 2.6.1). Installed MySQL 5.1.45 x86_64.

I download the source for mysql-python and compile with the following commands:

tar xzf MySQL-python-1.2.3c1.tar.gz
cd MySQL-python-1.2.3c1
ARCHFLAGS='-arch x86_64' python build
ARCHFLAGS='-arch x86_64' python install

And am getting the following error when I try to import:

Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.6-universal/egg/MySQLdb/", line 19, in <module>

  File "build/bdist.macosx-10.6-universal/egg/", line 7, in <module>
  File "build/bdist.macosx-10.6-universal/egg/", line 6, in __bootstrap__
ImportError: dlopen(/Users/derek/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/, 2): no suitable image found.  Did find:
/Users/derek/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/ mach-o, but wrong architecture

Any ideas? Or the best route for starting over.

share|improve this question

I also encountered this problem, and did not find a solution. Later changed to MySQL 32-bit, successfully installed the MySQL-Python, and problem solved~

share|improve this answer

Delete already installed files, then try installing with the following command :

sudo easy_install-2.6 mysql-python

share|improve this answer
Still getting an import error. ImportError: dynamic module does not define init function (init_mysql) – Derek Reynolds Mar 26 '10 at 23:21
Did you remove previously installed files ? – Studer Mar 26 '10 at 23:21

Did you try with macport?

sudo port install py26-mysql
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.