3

I'm newbie to python . I want to compile .c files generated by cython into .exe files . now i know there are programs like py2exe or cx_Freeze that can do the same but i want to make standalone executables (if possible) . now when i try to compile the cython .c file into exe using

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

Compiling with cl as explained in Can Cython compile to an EXE?

I get errors

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

please help

Community
  • 1
  • 1
HaMAD
  • 787
  • 2
  • 6
  • 11
  • py2exe can be used to create a stand-alone executable, and is probably your best bet. – Clarus Jul 02 '14 at 16:55
  • :/ Py2exe doesn't work for me . i'm using cx_Freeze for "freezing" @Claris – HaMAD Jul 02 '14 at 17:54
  • This looks oddly like this [other question](http://stackoverflow.com/questions/2211030/failing-to-compile-a-project-missing-io-h-file). I'd bet the issue is something like that. Here are two [other](http://stackoverflow.com/questions/5105482/compile-main-python-program-using-cython) [questions](http://stackoverflow.com/questions/22507592/making-an-executable-in-cython/22513682#22513682) that already discuss the general process of making an executable from Cython if you'd like to look at them. – IanH Jul 02 '14 at 20:03
  • They're different . n i guess @Claris is right . Cython is not for compiling executables . thanks – HaMAD Jul 03 '14 at 08:54

1 Answers1

1

If you just want to create standalone executables I recommend you to use PyInstaller, easily downloadable on Windows (I suppose you are using Windows) by command prompt with:

pip install pyinstaller

(remember to add pip path to environment variables) or on Mac Os X:

we strongly recommend that you install these using either MacPorts or Homebrew.

Documentation here.

Pyinstaller can compile .py files in standalone executables with the following command:

pyinstaller yourfilename.py -F

You can also add --windowed flag to make it a process (to hide console)

Federico Rubbi
  • 714
  • 3
  • 16
  • 1
    Note, that pyinstaller (or py2exe) is just the python interpreter packaged with your code and not a "real" standalone executable. – Wrench56 Dec 28 '22 at 00:43