在 Mac OS X 上安装 MySQLdb
我花了几个小时尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
sudo pip install mysql-python
在 10.8.1 中为我工作。sudo pip install mysql-python
worked for me in 10.8.1.确认。我感受到你的痛苦。我花了很长时间试图让 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...
在 .bashrc 或 .bash_profile 中尝试这个
try this in .bashrc or .bash_profile
您还可以强制 python 以 32 位模式运行:
You can also force python to run in 32bit mode: