2011-07-20 90 views
1

我正在尝试安装MySQLdb python,并且因为遇到体系结构错误而无法正常工作。安装MySQLdb Python体系结构错误

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

这是一个常见的问题,我看了很多很多来源,包括:

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

和许多其他链接。

看来问题是32位64位不匹配,但我不确定正确的组合是什么,或者不匹配是什么。

我已经从pip,从Mac端口安装,并从源代码构建。我试图将ARCHFLAGS设置为i386x86_64

我试过设置VERSIONER_PYTHON_PREFER_32_BITVERSIONER_PYTHON_PREFER_64_BIT首选项。

我运行Mac OS X 10.6.6

我有MySQL的安装在/usr/local/mysql

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

我有mysql版本5.5.12

我已经64 bit Python 2.6.6.

我的系统架构:

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

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

如果有任何链接,你可以指向我或建议尝试我会很感激。无论我尝试什么,我都处于死路一条,并得到相同的“错误架构”错误。

回答

0

我已经解决了自己的问题,所以希望这可以帮助人们与类似的问题。

我相信我有一个32位的MySQL安装。

我卸载的MySQL,我有

我回去,并从源头上安装的MySQL 5.1的所有版本,但我认为一个MySQL 5.1 x86_64的位伤害或二进制也将工作。

我这个职位http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/

我有权限问题用这个make命令,终于得到了它的工作使用

sudo mysqld_safe --skip-grant-tables & 

我从这里

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

安装了MySQL-python的1.2.3c1
2

尝试将其添加到您的.bashrc.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 
+0

我相信我用VERSIONER_PYTHON_PREFER试过这个选项,但那不是问题。 – jkeesh