在 Mac OS X 上安装 MySQLdb

发布于 2024-10-29 23:50:32 字数 964 浏览 0 评论 0原文

我花了几个小时尝试在 Mac OS X Snow Leopard 上安装 MySQLdb(Python 库)。我正在使用 这些说明来自 SO。我不断收到错误,因此我尝试使用 MacPorts(正如该问题的答案之一所建议的那样),但我仍然收到相同的错误。有人可以帮忙吗?

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/josephmornin/.python-egg-cache/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): no suitable image found.  
  Did find:
    /Users/josephmornin/.python-egg-cache/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture

I've spent several hours trying to install MySQLdb (the Python library) on Mac OS X Snow Leopard. I'm using these instructions from SO. I keep getting an error, so I've tried using MacPorts (as one of the answers to that question advises), but I continue to get the same error. Can anybody help?

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/josephmornin/.python-egg-cache/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): no suitable image found.  
  Did find:
    /Users/josephmornin/.python-egg-cache/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

坠似风落 2024-11-05 23:50:32

sudo pip install mysql-python 在 10.8.1 中为我工作。

sudo pip install mysql-python worked for me in 10.8.1.

北方的韩爷 2024-11-05 23:50:32

确认。我感受到你的痛苦。我花了很长时间试图让 MySQL 在 Snow Leopard 上使用 Macbook Air 与 Python 2.6 一起工作,但遇到了很多架构问题。最终为我解决这个问题的是确保我的 Python 和 MySQL 安装都使用 32 位架构,就像我的 Snow Leopard 一样。

我在这里写了我的解决方案,所以也许会有帮助:

http://www.markliu.me/2010/jun/09/mysql-and-python-on-32-bit-snow-leopard/

祝你好运...

Ack. I feel your pain. I spent a really long time also trying to get MySQL working with Python 2.6 on Snow Leopard using a Macbook Air and had lots of architecture problems. What ended up solving it for me, was making sure both my Python and MySQL installations were using a 32 bit architecture like my Snow Leopard was.

I wrote about my solution here, so maybe that'll help:

http://www.markliu.me/2010/jun/09/mysql-and-python-on-32-bit-snow-leopard/

Good luck...

七禾 2024-11-05 23:50:32

在 .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

try this in .bashrc or .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
生来就爱笑 2024-11-05 23:50:32

您还可以强制 python 以 32 位模式运行:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

You can also force python to run in 32bit mode:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文