Cython 代码:Python.h 没有那个文件或目录

Cython code : Python.h no such file or directory

当我使用 cython3 从 python3 代码生成 C 代码并尝试使用 gcc 编译生成的代码时,我收到此错误:test.c:4:20: fatal error: Python.h: Aucun fichier ou dossier de ce type .

我在网上查看了这个错误,所有的答案都是关于安装 python2-devpython3-dev ,但我已经在我的电脑上安装了这两个。我不仅有这两个,还有 python3.4-devpython3.5-dev

谁能给我这个错误的解决方案。

PS:我使用的是 Ubuntu 15.10,linux 版本 > 4。

您应该使用适当的路径进行编译,如下所示...

$ gcc -o test test.c `pkg-config --cflags --libs python3`

之前发生的事情是您没有包括适当的包含路径(由 pkg-config --cflags 检索)和 library/linking 路径(由 pkg-config --libs 检索)。包括两者,您的程序应该能够编译并且 link.