0
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.6-intel/egg/MySQLdb/__init__.py", line 19, in <module>
  File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/samwu/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/samwu/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture

我认为问题必须是python和mysql的64位版本,而img _mysql.so必须是32位

anybd可以给我一些建议吗

谢谢你!

------追加1------

我只是通过修改 setup_posix.py 中的mysql_config.path = options['mysql_config']来安装MySQLdb,然后像这样重建python setup.py build并安装,mysql_config 指向你的 mysql

------追加2------

我可以导入 MySQLdb,但它在 pydev 中不起作用

我在 python shell 中检查了 MySQLdb 模块的位置,如下所示:

import MySQLdb
print MySQLdb.__file__

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg/MySQLdb/_ init _.pyc

然后我将鸡蛋添加到我的 pydev lib.it 工作

[关闭]

4

1 回答 1

0

你安装了多个版本的python吗?它可能已安装到您的非默认版本,因此无法使用。

于 2012-06-16T05:35:47.940 回答