We have a Py module we'd like to give to users in the form of a windows executable. Is there a good tried and true tool to package a py module to Windows exe?
-
@mgilson you should make that an answer rather than a comment.Duncan– Duncan2012-07-23 13:16:03 +00:00Commented Jul 23, 2012 at 13:16
-
3Note that there aren't solutions that will compile Python in to opaque byte or machine code, really, only tools that will give you the ability to distribute a 1-click-runnable Python program.Silas Ray– Silas Ray2012-07-23 13:16:34 +00:00Commented Jul 23, 2012 at 13:16
-
@mgilson we did, but it currently depends on/built for py2.6 our dev environment is set for py 2.7rdodev– rdodev2012-07-23 13:20:17 +00:00Commented Jul 23, 2012 at 13:20
-
@sr2222 that's exactly what we're looking for. Not looking for a compiler but rather for a "standalone" executable for machines w/o py.rdodev– rdodev2012-07-23 13:21:50 +00:00Commented Jul 23, 2012 at 13:21
-
@Duncan -- I didn't feel confident enough to make it an answer as I've never used py2exe myself. I've just seen it referenced a bunch of times.mgilson– mgilson2012-07-23 13:23:54 +00:00Commented Jul 23, 2012 at 13:23
3 Answers
As an alternative to py2exe if you're running a 3.x version of Python, you can use cx_freeze (http://cx-freeze.sourceforge.net/). It doesn't package the program into a single executable, but you can package all the files it generates into a self-extracting archive for deployment. See https://stackoverflow.com/a/11511735/369977 for details.
Comments
You can use Python extention py2exe.
In Python you can use the code:
from distutils.core import setup
import py2exe
setup(console=['test.py'])
to make the executable test.exe
8 Comments
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
So long as you have py2exe installed it will compile hello.py to an exe, (it actually just bundles the stdlib and interpreter into an executable.)