python easy_install:指定存放所需文件的目录

发布于 2024-10-13 06:16:24 字数 443 浏览 7 评论 0原文

我正在尝试使用 easy_install 来安装 MySQL-python。它几乎立即失败:

_mysql.c:36:23: 错误: my_config.h: 没有这样的文件或目录
_mysql.c:38:19: 错误: mysql.h: 没有这样的文件或目录
_mysql.c:39:26: 错误: mysqld_error.h: 没有这样的文件或目录
_mysql.c:40:20: 错误: errmsg.h: 没有这样的文件或目录

它找不到标头。我已经安装了标头,它们只是从 /opt 中的源代码安装的。显然不是在看那里。我怎样才能让它看起来在那里?例如,如果这是配置,我可以执行类似“--with-mysql=/opt/mysql”的操作。 easy_install 似乎没有这样的选项。仍在研究,因此如果我找到答案,我会将其发布在这里。

I'm trying to use easy_install to install MySQL-python. It fails almost immediately:

_mysql.c:36:23: error: my_config.h: No such file or directory
_mysql.c:38:19: error: mysql.h: No such file or directory
_mysql.c:39:26: error: mysqld_error.h: No such file or directory
_mysql.c:40:20: error: errmsg.h: No such file or directory

It can't find the headers. I have the headers installed, they're just installed from source in /opt. It's obviously not looking there. How do I make it look there? For example, if this was configure, I could do something like "--with-mysql=/opt/mysql". It doesn't appear there is such an option with easy_install. Still researching so if I find my answer I'll post it here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

成熟的代价 2024-10-20 06:16:24

这看起来更像是编译器搜索路径的问题,而不是 easy_install 问题。

在 easy_install 调用之前设置包含路径环境变量可能会起作用。

C_INCLUDE_PATH=/path/to/your/mysql/include/files easy_install intall MySQL-python

如果这不起作用,请尝试设置 INCLUDE_PATH 或 CPLUS_INCLUDE_PATH 变量。问题中没有足够的 easy_install 输出来判断正在使用的编译器。

This looks more like an issue with the compiler search path than a easy_install issu.

Setting the include path environment variable before the easy_install call may work.

C_INCLUDE_PATH=/path/to/your/mysql/include/files easy_install intall MySQL-python

If that doesn't work, try setting the INCLUDE_PATH or CPLUS_INCLUDE_PATH variables. There wasn't enough easy_install output in the question to tell what compiler is being used.

隔岸观火 2024-10-20 06:16:24

easy_install 调用 setup.py,它将尊重它尝试安装的发行版中的 setup.cfg 文件。虽然您无法直接向 easy_install 指定 setup.py 选项 --include_dirs--library_dirs,但您可以将它们放在 setup.cfg 文件中。

我对 pysqlite 也有类似的问题:我将 SQLite 放在非标准位置,并想使用 easy_install 来获取 Python 绑定。 pysqlite 发行版包含一个 setup.cfg 文件,其中包含示例 include_dirs 和library_dirs 指令,因此很清楚要做什么。

如果 MySQL-python 有 setup.cfg 文件,您可以尝试添加/编辑它以包括:

[build_ext]
include_dirs = /path/to/headers
library_dirs = /path/to/libs

如果 setup.cfg 文件中已有 [build_ext] 部分,请添加到其中而不是创建第二个。

easy_install invokes setup.py, which will respect a setup.cfg file in the distribution it's trying to install. Although you cannot specify the setup.py options --include_dirs and --library_dirs directly to easy_install, you can put them in the setup.cfg file.

I have a similar issue with pysqlite: I put SQLite in a non-standard location, and wanted to use easy_install to get the Python bindings. The pysqlite distribution includes a setup.cfg file with sample include_dirs and library_dirs directives, so it was clear what to do.

If MySQL-python has a setup.cfg file, you could try adding / editing it to include:

[build_ext]
include_dirs = /path/to/headers
library_dirs = /path/to/libs

If there's already a [build_ext] section in the setup.cfg file, add to it instead of creating a second one.

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