python easy_install:指定存放所需文件的目录
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这看起来更像是编译器搜索路径的问题,而不是 easy_install 问题。
在 easy_install 调用之前设置包含路径环境变量可能会起作用。
如果这不起作用,请尝试设置 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.
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.
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 文件,您可以尝试添加/编辑它以包括:
如果 setup.cfg 文件中已有
[build_ext]
部分,请添加到其中而不是创建第二个。easy_install
invokessetup.py
, which will respect asetup.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:
If there's already a
[build_ext]
section in the setup.cfg file, add to it instead of creating a second one.