简体   繁体   English

Cython代码:Python.h没有这样的文件或目录

[英]Cython code : Python.h no such file or directory

when I generate C code from python3 code with cython3 and try to compile with gcc the resulting code, I get this error : test.c:4:20: fatal error: Python.h: Aucun fichier ou dossier de ce type . 当我使用cython3从python3代码生成C代码并尝试使用gcc编译生成的代码时,我收到此错误: test.c:4:20: fatal error: Python.h: Aucun fichier ou dossier de ce type

I looked over the web for this error, and all the answer were about installing python2-dev or python3-dev , but I already have this two installed in my computer. 我查看了网页上的这个错误,所有答案都是关于安装python2-devpython3-dev ,但我已经在我的计算机上安装了这两个。 I don't only have these two, but I have python3.4-dev and python3.5-dev too. 我不仅有这两个,但我也有python3.4-devpython3.5-dev

So can anyone give me the solution to this error. 所以任何人都可以给我这个错误的解决方案。

PS : I am using Ubuntu 15.10 with linux version > 4 . PS:我正在使用Ubuntu 15.10,linux版本> 4。

You should compile using the appropriate paths, like this... 你应该使用适当的路径编译,像这样...

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

What happened before is that you weren't including the appropiate include paths (retrieved by pkg-config --cflags ) and library/linking paths (retrieved by pkg-config --libs ). 以前发生的事情是你没有包括适当的包含路径(由pkg-config --cflags检索)和库/链接路径(由pkg-config --libs检索)。 Including both, your program should be able to compile and link. 包括两者,你的程序应该能够编译和链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM