借助@birryree的评论,我发现了这个问题。按照@birryrree在他的回答中建议的步骤来做可能会更好,但我以前确实尝试过,而且成功了:
按照建议,我做到了:file /Users/aj/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-ix86_64.egg-tmp/_mysql.so
获取:[...]: Mach-O bundle i386
所以,错误的架构。从那以后,我对mysql和python也做了同样的操作,以确保:
file $(which python)给出:/Library/Frameworks/Python.framework/Versions/2.7/bin/python: Mach-O universal binary with 2 architectures
/Library/Frameworks/Python.framework/Versions/2.7/bin/python (for architecture i386): Mach-O executable i386
/Library/Frameworks/Python.framework/Versions/2.7/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
以及file $(which mysql):/usr/local/mysql/bin/mysql: Mach-O 64-bit executable x86_64
所以我卸载了mysql python包:sudo pip uninstall mysql-python并再次安装。但这样做,我意识到我之前的错误,而安装这个包。我第一次打字:
sudo ARCHFLAGS='-arch ix86_64' python setup.py build(然后“安装”)
架构名称错误,应该是'-arch x86_64',没有“i”,所以它忽略了我的标志并安装了32位。
安装下载的64位mysql python包的正确命令(从源文件夹中):sudo ARCHFLAGS='-arch x86_64' python setup.py build
sudo ARCHFLAGS='-arch x86_64' python setup.py install