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

错误提示

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

1 PATH="/usr/local/mysql/bin:${PATH}"
2 export PATH
3 export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
4 export VERSIONER_PYTHON_PREFER_64_BIT=yes
5 export VERSIONER_PYTHON_PREFER_32_BIT=no

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

1 ARCHFLAGS="-arch x86_64" python setup.py build#64bit使用这个
2 ARCHFLAGS="-arch i386" python setup.py build#32bit使用这个
3  
4 sudo python setup.py install

3 开发环境IDE里设置DYLD_LIBRARY_PATH

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

4 检查

view source
print ?
1 #python
2 >>import _mysql

你可能感兴趣的:(python,Build,Path,import,library,64bit)