Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 54f1d8ca4d
Fetching contributors…

Cannot retrieve contributors at this time

108 lines (67 sloc) 3.22 kb

Freezing Your Code

An alternative to shipping your code is freezing it — shipping it as an executable with a bundled Python interpreter.

Many applications you use every day do this:

  • Dropbox
  • BitTorrent
  • ...

Comparison

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 no MIT yes yes no no
pyInstaller yes yes yes no GPL yes no yes no
cx_Freeze yes yes yes yes PSF no yes yes no

Note

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

Note

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

Windows

bbFreeze

Prerequisite is to install :ref:`Python, Distribute and pywin32 dependency on Windows <install-windows>`.

py2exe

Prerequisite is to install :ref:`Python on Windows <install-windows>`.

  1. Download and install http://sourceforge.net/projects/py2exe/files/py2exe/

  2. Write setup.py (List of configuration options):

    from distutils.core import setup
    import py2exe
    
    setup(
        windows=[{'script': 'foobar.py'}],
    )
    
  3. (Optionally) include icon

  4. (Optionally) one-file mode

  5. Generate .exe into dist directory:

    $ python setup.py py2exe
    
  6. Provide the Microsoft Visual C runtime DLL. Two options: globally install dll on target machine or distribute dll alongside with .exe.

PyInstaller

Prerequisite is to have installed :ref:`Python, Distribute and pywin32 dependency on Windows <install-windows>`.

OSX

py2app

PyInstaller

Linux

bbFreeze

PyInstaller

Jump to Line
Something went wrong with that request. Please try again.