2015-03-02 83 views
-1

我只是写了一个简单的C代码,以检查是否Python.h是否工作错误而使用Python.h

#include<Python.h> 
#include<stdio.h> 
int main() 
{ 
    printf("this is a python header file included programm\n"); 
    return 0; 
} 

可以明显看出它不会做much.The问题是,当我尝试编译用gcc它会给出错误。

foo.c:1:19: fatal error: Python.h: No such file or directory. 

然后我试着检查我的python-dev软件包是否已经安装了Python.h或者没有使用locate。

$locate Python.h 

这给我的路径

$/usr/include/python2.7/Python.h 

现在,很明显,我有Python.h头文件对我system.How我会得到它的工作?

+3

您是否尝试过加入'-I/usr/include目录/ python2.7'你'CFLAGS'? – cel 2015-03-02 18:20:03

回答

0

尝试instaling:

sudo apt-get install python-dev 

当编译运行是这样的:

gcc -Wall -I/usr/include/python2.7 -lpython2.7 nameOfProgram.c -o name