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 文件


- 我如何透明地重定向一个Python导入? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01