将Cython生成的.c文件编译为exe文件

时间:2014-07-02 16:08:32

标签: python c compilation executable cython

我是python的新手。我想将cython生成的.c文件编译成.exe文件。现在我知道有像py2exe或cx_Freeze这样的程序可以做同样的但我想制作独立的可执行文件(如果可能的话)。现在当我尝试将cython .c文件编译成exe时 使用

cl.exe  /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\Python\include -Ic:\Python\PC /Tctest.c /link /OUT:"test.exe" /SUBSYSTEM:CONSOLE /MACHINE:X86 /LIBPATH:c:\Python\libs /LIBPATH:c:\Python\PCbuild

使用cl进行编译,如中所述 Can Cython compile to an EXE?

我收到错误

c:\Python\include\pyconfig.h(68) : fatal error C1083: Cannot open include file:'io.h': No such file or directory

请帮助

1 个答案:

答案 0 :(得分:1)

如果您只想创建独立的可执行文件,我建议您使用PyInstaller,可以通过命令提示符在Windows上轻松下载(我想您使用的是Windows):

pip install pyinstaller

(记得向环境变量添加pip路径)或Mac Os X:

  

我们强烈建议您使用MacPorts或Homebrew安装这些。

文档here

Pyinstaller可以使用以下命令编译独立可执行文件中的.py文件:

pyinstaller yourfilename.py -F

您还可以添加--windowed标志以使其成为一个进程(隐藏控制台)

相关问题