zipapp | Python Standard Library – Real Python

The Python zipapp module provides tools for creating standalone executable Python applications packaged as ZIP files. With zipapp, you can quickly bundle and share your Python applications as a single file.

Here’s a quick example:

Packages the app/ directory into a app.pyz executable archive.

Key Features

  • Packages Python applications into a single ZIP file
  • Supports specifying entry points for the application
  • Allows setting the interpreter for running the application
  • Supports compressed and uncompressed archives
  • Enables cross-platform distribution of Python apps
  • Allows specifying shebang lines for custom interpreters
  • Integrates with command-line tools for easy automation

Frequently Used Commands and Options

Command / Option Description
python -m zipapp app Creates an executable archive (app.pyz) from the app/ directory
python -m zipapp app -o myapp.pyz Specifies the output file name (myapp.pyz)
python -m zipapp app -m main:main Sets the entry point (main.py with a main() function)
python -m zipapp app --python="/usr/bin/python3.13" Sets the interpreter path to use as the shebang line
python -m zipapp app --compress Creates a compressed archive for reduced file size
python -m zipapp --help Displays help and available options

Frequently Used Classes and Functions

Examples

Specify an entry point for the application:

Common Use Cases

  • Packaging Python applications for distribution
  • Creating standalone executables for easier deployment
  • Specifying custom entry points and interpreters for applications
  • Distributing command-line tools as single-file executables
  • Bundling dependencies for offline or portable execution
  • Automating build and deployment pipelines
  • Providing quick-start demos or self-contained examples

Real-World Example

Here’s how you can package a simple Python application with a custom entry point from the command line:

This command creates an app.pyz file, which you can run using Python. With this command, you create a portable app that’s ready to run anywhere—no installation or extra setup needed.

Python's zipapp: Build Executable Zip Applications