编译器找不到Python.h

时间:2021-09-19 23:16:57

I'm kinda new to C, and I can't seem to do what I want. I need to make some Python bindings for C functions, and I think I can figure this out. But there's one little line that WILL NOT WORK.

我对C有点陌生,我似乎不能做我想做的事。我需要为C函数做一些Python绑定,我想我可以算出来。但是有一条线不行。

#include <Python.h>

I get this:

我得到了这个:

fatal error #1035: Can't find include file <Python.h>.

I've tried everything. I just stuck Python.h in the same folder as my project first. Then I put the file name in Library and Object files under linker. Then I did the same with python31.lib, then I put the directory python31.lib is in in my PATH variable. Nothing will let me get past this line. I see a lot of solutions on the net for Linux, but none for Windows. Please help!

我试着一切。我只是困Python。h和我的项目在同一个文件夹里。然后我将文件名放在库中,对象文件放在链接器下。然后我用python31做了同样的事情。然后我把目录python31。lib在路径变量中。没有什么能让我越过这条线。我在网上看到了很多Linux的解决方案,但是没有一个是针对Windows的。请帮助!

2 个解决方案

#1


2  

Whoops, answered in a comment. Here's a more answerly answer.

哎呀,回答了一句评论。这里有一个更有答案的答案。

Make sure you put Python.h in your include path and the library in your library path.

确保你放了Python。h在包含路径中,库在库路径中。

#2


2  

Try:

试一试:

sudo apt-get install python2.6-dev

if your Python version is python2.6

如果您的Python版本是python2.6

#1


2  

Whoops, answered in a comment. Here's a more answerly answer.

哎呀,回答了一句评论。这里有一个更有答案的答案。

Make sure you put Python.h in your include path and the library in your library path.

确保你放了Python。h在包含路径中,库在库路径中。

#2


2  

Try:

试一试:

sudo apt-get install python2.6-dev

if your Python version is python2.6

如果您的Python版本是python2.6