I\'m building a Python application and don\'t want to force my clients to install Python and modules.
So, is there a way to compile a Python script to be a standalone
Since it seems to be missing from the current list of answers, I think it is worth mentioning that the standard library includes a zipapp module that can be used for this purpose. Its basic usage is just compressing a bunch of Python files into a zip file with extension .pyz
than can be directly executed as python myapp.pyz
, but you can also make a self-contained package from a requirements.txt
file:
$ python -m pip install -r requirements.txt --target myapp
$ python -m zipapp -p "interpreter" myapp
Where interpreter
can be something like /usr/bin/env python
(see Specifying the Interpreter).
Usually, the generated .pyz
/ .pyzw
file should be executable, in Unix because it gets marked as such and in Windows because Python installation usually registers those extensions. However, it is relatively easy to make a Windows executable that should work as long as the user has python3.dll
in the path.
If you don't want to require the end user to install Python, you can distribute the application along with the embeddable Python package.