zipapp
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:
>>> import zipapp
>>> zipapp.create_archive("app", target="app.pyz")
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
Object | Type | Description |
---|---|---|
zipapp.create_archive() |
Function | Creates a ZIP archive from a directory |
zipapp.get_interpreter() |
Function | Retrieves the interpreter path for the archive |
zipapp.main() |
Function | Provides a command-line interface for creating archives |
Examples
Specify an entry point for the application:
>>> import zipapp
>>> zipapp.create_archive("app", target="app.pyz", main="main:main")
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:
$ python -m zipapp app -o app.pyz -m "main:main"
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.
Related Resources
Tutorial
Python's zipapp: Build Executable Zip Applications
In this step-by-step tutorial, you'll learn what Python Zip applications are and how to create them quickly using the zipapp module from the standard library. You'll also learn some alternative tools you can use to build this kind of application manually.
By Leodanis Pozo Ramos • Updated July 30, 2025