Mac OS X:本地 Django 出现问题 + PyDev 安装与远程 MySQL 一起使用

发布于 2024-09-17 10:03:08 字数 819 浏览 9 评论 0原文

我已经在 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 技术交流群。

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

发布评论

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

评论(3

离不开的别离 2024-09-24 10:03:08

一句话,不。您需要 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.

累赘 2024-09-24 10:03:08

为什么不使用 macports 来代替呢?它还有一个名为 porticus 的 GUI。

Why not use macports instead. It also has a gui called porticus.

沉鱼一梦 2024-09-24 10:03:08
pip install mysql-python

...或者如果您没有pip,请使用easy_install

pip install mysql-python

... or use easy_install if you don't have pip.

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