1

I am trying to install MySQLdb python and am having trouble getting it to work because I get an architecture error.

>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.6-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
  File "build/bdist.macosx-10.6-x86_64/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.6-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/jkeesh/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-x86_64.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/jkeesh/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-x86_64.egg-tmp/_mysql.so: mach-o, but wrong architecture

This has been a common question, and I have read many, many sources including:

Python MySQL wrong architecture error

http://www.mechanicalgirl.com/view/installing-django-with-mysql-on-mac-os-x/

Django + MySQL on Mac OS 10.6.2 Snow Leopard

Installing MySQLdb on Mac OS X

and many other links.

It appears that the problem is a 32-bit 64-bit mismatch, but I'm not sure what the right combination is, or what exactly the mismatch is.

I have installed from pip, from Mac ports, and built from the source. I have tried setting the ARCHFLAGS to both i386 and and x86_64.

I have tried setting VERSIONER_PYTHON_PREFER_32_BIT and VERSIONER_PYTHON_PREFER_64_BIT preferences.

I am running Mac OS X 10.6.6

I have mysql installed in /usr/local/mysql

$ file $(which ./mysql)
   ./mysql: Mach-O executable i386

I have mysql version 5.5.12

I have 64 bit Python 2.6.6.

My system architecture is:

>>> platform.platform()
'Darwin-10.6.0-i386-64bit'

$ file $(which python) 
   /opt/local/bin/python: Mach-O 64-bit executable x86_64

If there are any links you can point me to or suggestions to try I would really appreciate it. I'm kind of at a dead end and getting the same "wrong architecture" error no matter what I try.

2 Answers 2

2

Try to add this in your .bashrc or .bash_profile:

PATH="/usr/local/mysql/bin:${PATH}"
export PATH
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
export VERSIONER_PYTHON_PREFER_64_BIT=no
export VERSIONER_PYTHON_PREFER_32_BIT=yes
Sign up to request clarification or add additional context in comments.

1 Comment

I believe I tried that options with VERSIONER_PYTHON_PREFER, but that wasn't the problem.
0

I've solved my own question, so hopefully this can be of help to people with similar issues.

I believe I had a 32-bit mysql installation.

I uninstalled all versions of mysql that I had

I went back and installed mysql 5.1 from the source, but I think a mysql 5.1 x86_64 bit dmg or binary would work also.

I used this make command from this post http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/

I had permission issues and finally got it working using

sudo mysqld_safe --skip-grant-tables &

I installed MySQL-python 1.2.3c1 from here

http://pypi.python.org/pypi/MySQL-python/1.2.3c1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.