Differences

This shows you the differences between two versions of the page.

Link to this comparison view

py2exe [2014/10/26 01:52] (current)
Line 1: Line 1:
 +===== Compile .py file to .exe for Windows =====
 +
 +[[http://​www.py2exe.org|Py2exe]] is a freeware utility which will build an .exe from .py file(s)
 +
 +To build an .exe under windows create a file for example setup.py which includes some py2exe attributes. The following example creates a HelloWorld.exe which prints the 'Hello World' greeting 25 times.
 +
 +<code python>
 +for i in range(25):
 + print "Hello World " + str(i+1)
 +</​code>​
 +
 +For this example I use setup.py which is as follows:
 +
 +<code python>
 +from distutils.core import setup
 +import py2exe
 +
 +setup(console=['​hello.py'​])
 +</​code>​
 +
 +To build the exe run the setup with the option py2exe.
 +
 +<code bat>
 +setup.py py2exe
 +</​code>​
 +
 +This will create a folder called dist (default), where you will find all files releated to executing hello.exe including any necessary DLL files. At this point you may using a Win installer like NullSoft installer [[http://​nsis.sourceforge.net/​Main_Page|NSIS]] to build an installer for the hello.exe.
 +
 +Py2exe supports most modules, please refer to their home page for more options and examples.
 +
 +
 +
 +
 +----
 +* [[pythoninfo|Back to Python]]
  
py2exe.txt ยท Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0