【问题标题】:Installing MySQLdb Python Architecture Error安装 MySQLdb Python 架构错误
【发布时间】:2011-10-09 03:49:47
【问题描述】:

我正在尝试安装 MySQLdb python,但由于出现体系结构错误而无法使其正常工作。

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

这是一个常见的问题,我阅读了很多很多资料,包括:

Python MySQL wrong architecture error

http://www.mechanicalgirl.com/view/installing-django-with-mysql-on-mac-os-x/

Django + MySQL on Mac OS 10.6.2 Snow Leopard

Installing MySQLdb on Mac OS X

还有许多其他链接。

问题似乎是 32 位 64 位不匹配,但我不确定正确的组合是什么,或者不匹配到底是什么。

我从 pip、Mac 端口安装,并从源代码构建。我尝试将ARCHFLAGS 设置为i386x86_64

我已尝试设置 VERSIONER_PYTHON_PREFER_32_BITVERSIONER_PYTHON_PREFER_64_BIT 首选项。

我正在运行 Mac OS X 10.6.6

我在/usr/local/mysql安装了mysql

$ file $(which ./mysql)
   ./mysql: Mach-O executable i386

我有mysql版本5.5.12

我有64 bit Python 2.6.6.

我的系统架构是:

>>> platform.platform()
'Darwin-10.6.0-i386-64bit'

$ file $(which python) 
   /opt/local/bin/python: Mach-O 64-bit executable x86_64

如果有任何链接可以指点我或建议尝试,我将不胜感激。无论我尝试什么,我都陷入了死胡同,并且遇到了同样的“错误的架构”错误。

【问题讨论】:

    标签: mysql architecture 32bit-64bit mysql-python


    【解决方案1】:

    尝试将此添加到您的.bashrc.bash_profile

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

    【讨论】:

    • 我相信我使用 VERSIONER_PYTHON_PREFER 尝试了该选项,但这不是问题。
    【解决方案2】:

    我已经解决了我自己的问题,所以希望这对有类似问题的人有所帮助。

    我相信我安装了 32 位 mysql。

    我卸载了所有版本的mysql

    我回去并从源代码安装了 mysql 5.1,但我认为 mysql 5.1 x86_64 位 dmg 或二进制文件也可以。

    我在这篇文章http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/中使用了这个make命令

    我遇到了权限问题,终于可以使用

    sudo mysqld_safe --skip-grant-tables &
    

    我从这里安装了 MySQL-python 1.2.3c1

    http://pypi.python.org/pypi/MySQL-python/1.2.3c1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-15
      • 2011-09-23
      • 2013-12-02
      • 2011-03-06
      • 1970-01-01
      • 2013-07-26
      • 2021-07-30
      • 2021-06-08
      相关资源
      最近更新 更多