Python连接MySQLdb的mach-o, but wrong architecture错误解决

错误提示

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.6-x86_64.egg/_mysql.so: mach-o, but wrong architecture

这个问题是32bit和64bit的问题.
解决方法:
1 使用正确的环境编译MySQL-python-1.2.3.tar.gz,并安装
设置.bash_profile

PATH="/usr/local/mysql/bin:${PATH}"
export PATH
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
export VERSIONER_PYTHON_PREFER_64_BIT=yes
export VERSIONER_PYTHON_PREFER_32_BIT=no

2 编译安装MySQL-python-1.2.3.tar.gz

ARCHFLAGS="-arch x86_64" python setup.py build#64bit使用这个
ARCHFLAGS="-arch i386" python setup.py build#32bit使用这个

sudo python setup.py install

3 开发环境IDE里设置DYLD_LIBRARY_PATH

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

4 检查

#python
>>import _mysql

Tags: ,

星期六, 29 10 月, 2011 服务器

Leave a Reply

1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr