Freezing Your Code

To ‘Freeze’ your code is to distribute to end-users as an executable which includes a bundled Python interpreter.

Applications such as ‘Dropbox’, BitTorrent clients, ‘Eve Online’ and ‘Civilisation IV’ do this.

The advantage of distributing this way is that your application will work even if the user doesn’t already have the required version of Python installed. On Windows, and even on many Linux distributions and OSX versions, the right version of Python will not already be installed.

One disadvantage is that it will bloat your distribution by about 2MB. Another problem is that your application will not receive any security updates to the version of Python it uses unless you freeze a new version and get users to download it.

Alternatives to Freezing

Packaging your code is for distributing libraries or tools to other developers.

On Linux, an alternative to freezing is to create a Linux distro package (e.g. .deb files for Debian or Ubuntu, or .rpm files for Red Hat and SuSE.)


Fill in “Freezing Your Code” stub


Solutions and platforms/features supported:

Solution Windows Linux OS X Python 3 License One-file mode Zipfile import Eggs pkg_resources support
bbFreeze yes yes yes no MIT no yes yes yes
py2exe yes no no yes MIT yes yes no no
pyInstaller yes yes yes yes GPL yes no yes no
cx_Freeze yes yes yes yes PSF no yes yes no
py2app no no yes yes MIT no yes yes yes


Freezing Python code on Linux into a Windows executable was only once supported in PyInstaller and later dropped..


All solutions need MS Visual C++ dll to be installed on target machine, except py2app. Only Pyinstaller makes self-executable exe that bundles the dll when passing --onefile to



Prerequisite is to install Python, Setuptools and pywin32 dependency on Windows.


Write steps for most basic .exe


Prerequisite is to install Python on Windows.

  1. Download and install
  2. Write (List of configuration options):
from distutils.core import setup
import py2exe

    windows=[{'script': ''}],
  1. (Optionally) include icon
  2. (Optionally) one-file mode
  3. Generate .exe into dist directory:
$ python py2exe
  1. Provide the Microsoft Visual C runtime DLL. Two options: globally install dll on target machine or distribute dll alongside with .exe.