My question might already have been answered somewhere but still, I can't find a straightforward answer to it yet.
I want to create a standalone executable from python code. I've already tried a bunch of solutions like py2exe
, pyinstaller
, etc. But my problem is the large output file size. For example, in pyinstaller
a simple hello world compile to 5MB file. After a lot of searches I've found Cython
which creates a c file from python code then I tried to compile it with MSVC 2015
and generated the exe file but it depends on python3x.dll
file.
So Is there any way to compile the python code to stand alone exe file with a small size?
If it is not, how to bundle the executable file with msvc
?
I'm using python3.4 but is there any difference between python2 and 3 in this manner? I am using these commands to first generate c file then compile it to exe:
python -m cython test.py --embed
cl /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python34\include -Ic:\Python34\PC /Tctest.c /link /OUT:"test.exe" /SUBSYSTEM:CONSOLE /MACHINE:X64 /LIBPATH:c:\Python34\libs /LIBPATH:c:\Python34\PCbuild