在我看来,似乎无法让 mysql-python 在 Snow Leopard 上运行。
目前使用 Snow Leopard 自带的默认 Python 版本 ( python 2.6.1
)。已安装MySQL 5.1.45 x86_64
。
我下载了 mysql-python 的源代码http://sourceforge.net/projects/mysql-python/并使用以下命令进行编译:
tar xzf MySQL-python-1.2.3c1.tar.gz
cd MySQL-python-1.2.3c1
ARCHFLAGS='-arch x86_64' python setup.py build
ARCHFLAGS='-arch x86_64' python setup.py install
当我尝试导入时出现以下错误:
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/derek/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/derek/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture
有什么想法吗?或者重新开始的最佳路线。
答案1
我也遇到了这个问题,没有找到解决办法。后来换成 MySQL 32 位,成功安装 MySQL-Python,问题解决~
答案2
删除已安装的文件,然后尝试使用以下命令进行安装:
sudo easy_install-2.6 mysql-python
答案3
你试过吗麦克波特?
sudo port install py26-mysql