Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 http://sourceforge.net/projects/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 setup.py build
ARCHFLAGS='-arch x86_64' python setup.py 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/__init__.py", line 19, in <module>

  File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/derek/.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/derek/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture

Any ideas? Or the best route for starting over.

share|improve this question
add comment

3 Answers

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
add comment

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
add comment

Did you try with macport?

sudo port install py26-mysql
share|improve this answer
add comment

Your Answer

 
discard

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.