在 Mac OS X 上导入 Python 的 MySQLdb 时出错
我花了很长一段时间浏览 MySQL 博客和一些问题,试图弄清楚如何在我的 Mac OS 10.6.7 上安装 MySQL 服务器和 MySQLdb for Python。我想我通过 MacPorts 安装了 MySQL 服务器(这花了很长时间),但我无法导入 MySQLdb (从这里下载)使用Python。
这是我得到的错误:
import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/EPD64.framework/Versions/6.3/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.5-x86_64.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Frameworks/EPD64.framework/Versions/6.3/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.5-x86_64.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/EPD64.framework/Versions/6.3/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.5-x86_64.egg/_mysql.so
Reason: image not found
我按照 这个问题用于清理并重新安装我的 MySQLdb 安装。完成这些步骤一切正常,但它导致了同样的错误。
我也不确定为什么它调用 EPD64.framework 目录——模块文件夹和内容实际上包含在 /Library/Frameworks/Python.Framework/.../site-packages 中。 MacPorts 是否可能在某个地方跨接了电线?
(我做了一个额外的步骤,将 site.cfg 中的 msyql_config 路径修改为 /user/local/mysql/bin/mysql_config )
我还尝试遵循 这个问题但根本找不到 /User/$User/.python-eggs 目录,所以不知道该怎么办那。
有什么想法吗?
I've spent what feels like forever running down MySQL blogs and SO questions trying to figure out how to install a MySQL server and MySQLdb for Python on my Mac OS 10.6.7. I think I got the MySQL server installed through MacPorts(which took an eternity), but I can't import MySQLdb (downloaded from here) with Python.
Here's the error I get:
import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/EPD64.framework/Versions/6.3/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.5-x86_64.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Frameworks/EPD64.framework/Versions/6.3/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.5-x86_64.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/EPD64.framework/Versions/6.3/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.5-x86_64.egg/_mysql.so
Reason: image not found
I followed the instructions on this question for cleaning up and reinstalling my MySQLdb installation. Everything worked fine going through the steps, but it resulted in the same error.
I'm also not sure why it's calling the EPD64.framework directory -- the module folder and contents are actually contained in /Library/Frameworks/Python.Framework/.../site-packages. Could MacPorts have crossed the wires somewhere?
(I did one extra step of modifying the msyql_config path in site.cfg to /user/local/mysql/bin/mysql_config)
I also tried to follow the advice of this question but can't find the /User/$User/.python-eggs directory at all, so not sure what to do about that.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您问题中的第二个链接包含答案,但是其中包含了太多不必要的额外信息...
只需确保您有以下 bin:
/usr/local/mysql/bin/mysql_config
时,您需要做的就是将
setup_posix.py
中的mysql_config.path
更改为:尝试简单地这样做,不要执行他们建议的符号链接或清洗鸡蛋等。
The second link in your question kind of contains the answer, but there is so much extra information mucked in that's unnecessary...
Simply make sure you have the following bin:
/usr/local/mysql/bin/mysql_config
And then when installing MySQLdb all you need to do is change
mysql_config.path
insetup_posix.py
to:Try simply doing that, don't do the symlinks they suggest or clean the eggs etc.