导入 MySQLdb 时出错
我已经尝试了一段时间让 MySQLdb 工作。我目前收到此错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
Referenced from: /Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
Reason: image not found
有人知道我需要做什么才能纠正这些错误吗?
I have been trying for awhile now to get MySQLdb working. I am currently getting this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
Referenced from: /Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
Reason: image not found
Anyone know what I need to do in order to correct these errors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 MySQLdb 已针对错误的架构进行了自身编译。我正在运行 OSX Lion x86_64,我必须这样做:
和 64 位 MySQL
您可以验证当前 MySQLdb 的体系结构是 32 位:
然后我可以让 MySQLdb 工作的唯一方法是下载源代码,并使用
它 进行编译强制 setup.py 构建 64 位库 (_mysql.so) 而不是 32 位。 (帽子提示 - 我发现这个所以问题很有帮助
,丹。
It looks like MySQLdb has compiled itself for the wrong architecture. I'm running OSX Lion x86_64 and I had to do this:
and 64bit MySQL
You can verify the architecture of your current MySQLdb is 32bit:
And then the only way I could get MySQLdb to work was to download the source, and compile with
which forces the setup.py to build a 64 bit library (_mysql.so) rather than 32 bit. (Hat-tip - I found this so question to be helpful.
HTH, Dan