Py2exe
Suppose you don’t know if your Windows users have Python installed — or you don’t know which version of Python they’ve got installed. You can still distribute a Python program to them using py2exe.
Here’s how:
- Make sure that you yourself have Python
installed, and that you know which version you have installed
(
python -v
will tell you). - Visit http://www.py2exe.org/ to get an overview of what Py2exe does.
- Head over to the SourceForge and download the version of Py2exe which matches your version of Python
- Install Py2exe
- Look though the code samples to find something which matches what you need to do
- And do it!
Using Py2exe
Suppose you want to distibute my solution to the
8 Queens puzzle.
You need to create a file called setup.py
which looks like:
from distutils.core import setup import py2exe setup ( version = "1.0", name = "N Queens puzzle solver", console = ["queens.py"] )
Then run:
python setup.py py2exe
The executable and DLLs appear in the dist
subdirectory of your
current working directory.