找不到在CentOS Python.h文件 [英] Can't find Python.h file on CentOS

查看:545
本文介绍了找不到在CentOS Python.h文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译C语言编写的一个CentOS机器上的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上,在那里我已经安装使用的python-dev的精细apt-get的。

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的/ 。由于这条道路不是默认由pre-处理器搜查,你必须将它添加到路径搜索列表。这与 -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

以上更改你的系统上的实际路径。你可以找到它要么与 找到 作为评论与 定位的提出,指挥 如果是安装了命令。

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文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆