1

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?

6
  • @mgilson you should make that an answer rather than a comment.
    – Duncan
    Commented Jul 23, 2012 at 13:16
  • 3
    Note 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
    Commented 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.7
    – rdodev
    Commented 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
    Commented 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
    Commented Jul 23, 2012 at 13:23

3 Answers 3

2

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.

1

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
  • Aye, I was few secs to late. I see we Googled the same code :)
    – Gunnar
    Commented Jul 23, 2012 at 13:18
  • I just stole the tutorial directly from their website Commented Jul 23, 2012 at 13:19
  • likewise here. I don't understand why @Syrahn didn't Google it before asking. It was the first thing that popped up on the serach.
    – Gunnar
    Commented Jul 23, 2012 at 13:21
  • @Gunnar I did Google it before asking. Don't jump to conclusions. Firstly the project seems to have been abandoned since 2008, secondly it's only compatible with Py 2.6
    – rdodev
    Commented Jul 23, 2012 at 13:26
  • @Syrahn, really? There is a py2exe package for Python 2.7 in SourceForge.
    – Raceyman
    Commented Jul 23, 2012 at 14:08
0
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.)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.