Can#39;t find Python.h file on CentOS(在 CentOS 上找不到 Python.h 文件)
问题描述
我正在尝试在 CentOS 机器上编译用 C 编写的 Python 扩展.我得到了
I am trying to compile a Python extension written in C on a CentOS machine. I am getting
error: Python.h: No such file or directory
它在 ubuntu 上运行良好,我使用 apt-get 安装了 python-dev.
It works fine on ubuntu, where I have python-dev installed using apt-get.
我尝试使用安装 python-devel
I tried installing python-devel using
yum install python-devel
但它已经安装了.如何解决此错误?
but it is already installed. How do I fix this error?
推荐答案
在我的系统上,Python.h
头文件位于路径 /usr/include/python2.6/代码>.由于预处理器默认不搜索此路径,因此您必须将其添加到要搜索的路径列表中.这是通过编译器的
-I
选项完成的,如下所示:
On my system the Python.h
header file is in the path /usr/include/python2.6/
. As this path is not searched by the pre-processor by default, you have to add it to the list of paths to search. This is done with the -I
option to the compiler, like this:
$ gcc -I/usr/include/python2.6 source.c -o program
将上面的路径更改为系统上的实际路径.您可以使用 find
命令中的建议找到它locate
命令(如果已安装)的注释.
Change the path above to the actual path on your system. You can find it either with the find
command as proposed in a comment, of with the locate
command if it's installed.
这篇关于在 CentOS 上找不到 Python.h 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 CentOS 上找不到 Python.h 文件


基础教程推荐
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 包装空间模型 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 求两个直方图的卷积 2022-01-01