使用Python.h时出错
我刚刚编写了一个简单的c代码来检查Python.h是否正常工作使用Python.h时出错,python,python-2.7,ubuntu,python-3.x,cython,Python,Python 2.7,Ubuntu,Python 3.x,Cython,我刚刚编写了一个简单的c代码来检查Python.h是否正常工作 #include<Python.h> #include<stdio.h> int main() { printf("this is a python header file included programm\n"); return 0; } 然后,我尝试检查我的python开发包是否安装了python.h或没有使用locate $locate Python.h 这给了我一条路 $/usr
#include<Python.h>
#include<stdio.h>
int main()
{
printf("this is a python header file included programm\n");
return 0;
}
然后,我尝试检查我的python开发包是否安装了python.h或没有使用locate
$locate Python.h
这给了我一条路
$/usr/include/python2.7/Python.h
现在,很明显,我的系统上有Python.h头文件。如何使其工作?尝试安装:
sudo apt-get install python-dev
编译时,请运行以下操作:
gcc -Wall -I/usr/include/python2.7 -lpython2.7 nameOfProgram.c -o name
您是否尝试将
-I/usr/include/python2.7
添加到您的CFLAGS
?
gcc -Wall -I/usr/include/python2.7 -lpython2.7 nameOfProgram.c -o name