Cython致命错误:Python。没有这样的文件或目录

时间:2021-03-14 18:18:41

I have been using Cython to compile my Python files into C files and then use MinGW to create an executable from the C file. Cython works fine, I can type cython test.pyx into the command line and get a C file. The problem is when I attempt to compile an executable from the C file. If I type gcc test.c I get the following error:

我一直在使用Cython将Python文件编译成C文件,然后使用MinGW从C文件创建可执行文件。Cython运行良好,我可以输入Cython测试。将pyx放入命令行并获得一个C文件。问题是当我试图从C文件编译可执行文件时。如果我输入gcc测试。c我得到以下错误:

test.c:4:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.

I would really appreciate some help. I am running windows 7 and python 3.5.

我非常感谢你的帮助。我正在运行windows 7和python 3.5。

2 个解决方案

#1


4  

in gcc

在gcc

#include "file.h"

tells gcc to find the file in the same directory where test.c is, and

告诉gcc在测试的相同目录中查找文件。c是,

#include <file.h>

means to find file.h in the gcc include paths, which can be added with -I

意味着找到文件。gcc中的h包含路径,可以用-I添加

gcc -I/path/to/the/file_h test.c

you might try

您可以试一试

#include <Python.h>

also see fatal error: Python.h: No such file or directory

还可以看到致命错误:Python。h:没有这样的文件或目录

#2


5  

you probably don't have python-dev installed. Depending on your OS, you'd need to do something like this:

您可能没有安装python-dev。根据你的操作系统,你需要做这样的事情:

sudo apt-get install python-dev

Which is what you'd do on Ubuntu

在Ubuntu上你会怎么做

#1


4  

in gcc

在gcc

#include "file.h"

tells gcc to find the file in the same directory where test.c is, and

告诉gcc在测试的相同目录中查找文件。c是,

#include <file.h>

means to find file.h in the gcc include paths, which can be added with -I

意味着找到文件。gcc中的h包含路径,可以用-I添加

gcc -I/path/to/the/file_h test.c

you might try

您可以试一试

#include <Python.h>

also see fatal error: Python.h: No such file or directory

还可以看到致命错误:Python。h:没有这样的文件或目录

#2


5  

you probably don't have python-dev installed. Depending on your OS, you'd need to do something like this:

您可能没有安装python-dev。根据你的操作系统,你需要做这样的事情:

sudo apt-get install python-dev

Which is what you'd do on Ubuntu

在Ubuntu上你会怎么做