开发者

Installing MySQLdb Python Architecture Error

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 wro开发者_JAVA技巧ng 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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜