We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.


June 10, 1997 | Fredrik Lundh

Note: Squeeze was originally developed for Python 1.4, but still works with later versions. However, the current Squeeze release (from 1998) does not support Python packages.

The squeeze utility can be used to distribute a complete Python application as one or two files, and run it using a standard Python interpreter kit.

squeeze compiles all Python modules used by the application (except for the standard library files), and packs them all in a single, usually compressed “bytecode package”. The import statement is then modified (using the ihooks module) to look in the package before searching for modules on the disk. You can also put arbitrary data files in the package, and access them via the __main__ module.

The package itself can be stored in two different ways:

  1. As a separate binary package file (a PYZ file). In this case, squeeze also generates a small bootstrap script (typically 300 bytes) which locates and loads the package file. When using compression, the size of the resulting package is usually about 30% of the PY files; only slightly larger than a corresponding ZIP file.
  2. Embedded in a single Python script. This generates somewhat larger files, but the result is a single text file that can easily be mailed, posted, or used in other environments which may mess up your scripts. No lines are longer than 76 characters, and the file does not include any critical whitespace.

To generate and run squeezed applications (of any type), you need Python 1.4 or newer. To generate compressed packages, you need the ZLIB data compression module (which, of course, is also required to run the resulting package). Note that if the application itself is portable, the same package can be used on all platforms.


Squeeze can be downloaded from the effbot.org downloads area.


“Fredrik Lundh is a friggin genius”
— Aaron Watters, author of ‘Internet Programming with Python’

“I agree … this is a friggin Good Thing”
— Paul Everitt, Digital Creations