2015-03-02 80 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