py2exe

Source code => Windows exe

What is py2exe

py2exe turns Python programs into packages that can be run on other Windows computers without needing to install Python on those computers. You must run py2exe on a Windows computer. Python is needed on the computer where py2exe itself is run because py2exe is a Python program and it includes parts of Python in the package that is built.

Installation

pip3 install py2exe

Template

Write a program and save it as demo.py:

print('Hello World')

Save the following template as demo_setup.py:

import py2exe
from distutils.core import setup

setup(
	options={'py2exe' : {'bundle_files' : 1, 'compressed' : True}},
	console=[{'script' : 'demo.py'}],
	zipfile=None,
)

Pack:

python3 .\demo_setup.py py2exe

A dist folder will be generated and it contains everything we need to run the executable.

Last updated