Mac OS X:本地 Django 出现问题 + PyDev 安装与远程 MySQL 一起使用
我已经在 Eclipse 中安装了 PyDev。我正在尝试和 Django 一起玩。我已经设置了一个远程 MySQL 数据库。我真的不想在我的 MacBook 上安装 MySQL。
尝试为 python 设置 MySQL 插件时,我得到了
(djangotest)jeebus:MySQL-python-1.2.3 blah$ python setup.py clean
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/Users/nali/djangotest/temp/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/Users/nali/djangotest/temp/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
该错误,因为我没有设置任何 MySQL 或相关工具。
是否有 Snow Leopard MySQL 库可以用来满足 mysql_config 的需求,而无需实际安装 MySQL?
I've got PyDev installed in Eclipse. I'm trying to play with Django. I'm got a remote MySQL database set up. I would really like to not install MySQL on my MacBook.
Trying to set up the MySQL plugin for python, I get
(djangotest)jeebus:MySQL-python-1.2.3 blah$ python setup.py clean
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/Users/nali/djangotest/temp/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/Users/nali/djangotest/temp/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
The error makes sense since I don't have any of MySQL or related tools set up.
Are there an Snow Leopard MySQL libraries I can use to satisfy the need for mysql_config without actually installing MySQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一句话,不。您需要 MySQL 的客户端库,但不需要服务器组件。大多数包管理器将每个包作为单独的包提供。
MySQL-python,又称 MySQLdb,本身不是客户端模块。它是 Python 程序和标准 MySQL 客户端库之间的包装器或接口。 MySQLdb 符合 Python 标准 DB API。还有为其他数据库管理器实现的其他一致性适配器。使用通用 API 可以更轻松地用 Python 编写与数据库无关的代码;适配器处理(大部分)各种数据库客户端库之间的混乱差异。因此,您确实需要安装MySQL客户端库;有几种方法可以做到这一点:最简单的选择可能是从 mysql.com 下载预构建的库,或者您可以使用包管理器(如 MacPorts)来安装它们和其他依赖项。
对于 OS X 10.6,由于以兼容的方式安装所有必需的部分可能会遇到问题,我强烈建议使用 MacPorts 的整体解决方案来获得 Python MySQL 支持。有关更多详细信息,请参阅此处的答案。 MacPorts 甚至提供了 Django 端口。
In a word, no. You need the client side libraries of MySQL but you don't need the server components. Most package managers provide each as separate packages.
MySQL-python, AKA MySQLdb, is not a client module per se. It is a wrapper or interface between Python programs and the standard MySQL client libraries. MySQLdb conforms to the Python standard DB API. There are other conforming adapters implemented for other database managers. Using the common API makes it much easier to write database-independent code in Python; the adapters handle (much of) the messy differences among the various database client libraries. Thus, you do need to install MySQL client libraries; there are several ways to do this: the easiest options are probably downloading prebuilt libraries from mysql.com or you can use a package manager, like MacPorts, to install them and other dependencies.
For OS X 10.6, because of the potential gotchas in getting all of the needed pieces installed in a compatible manner, I highly recommend using a total solution from MacPorts to get Python MySQL support. See the answer here for more details. MacPorts even provides a Django port.
为什么不使用 macports 来代替呢?它还有一个名为 porticus 的 GUI。
Why not use macports instead. It also has a gui called porticus.
...或者如果您没有
pip
,请使用easy_install
。... or use
easy_install
if you don't havepip
.