You can use PyInstaller to package Python programs as standalone executables. It works on Windows, Linux, and Mac.
Answer from Rumple Stiltskin on Stack OverflowPyInstaller Quickstart
Install PyInstaller from PyPI:
pip install pyinstallerGo to your program’s directory and run:
pyinstaller yourprogram.pyThis will generate the bundle in a subdirectory called
dist.pyinstaller -F yourprogram.pyAdding -F (or --onefile) parameter will pack everything into single "exe".
pyinstaller -F --paths=<your_path>\Lib\site-packages yourprogram.pyrunning into "ImportError" you might consider side-packages.
pip install pynput==1.6.8still runing in Import-Erorr - try to downgrade pyinstaller - see Getting error when using pynput with pyinstaller
For a more detailed walkthrough, see the manual.
Hiya thanks for reading! I followed a tutorial and built a tiny game with pygame. I am trying to wrap it up in a single executable file I can send to a friend, such that they won't have to install anything to run it. I have unsuccessfully used p2exe and pyinstaller. Is there a standard way to package python applications? I can share my code or the tutorials/links I am looking at if that is desirable. In gratitude, Prathmun
How to compile the Python code to executable binary file like Linux C and Golang
How do I package my python code into an executable I can send to my friend who does not have python?
How can I turn a python project into a single .exe file?
Is it a good idea to compile python to exe and then distribute to users?
You can use PyInstaller to package Python programs as standalone executables. It works on Windows, Linux, and Mac.
PyInstaller Quickstart
Install PyInstaller from PyPI:
pip install pyinstallerGo to your program’s directory and run:
pyinstaller yourprogram.pyThis will generate the bundle in a subdirectory called
dist.pyinstaller -F yourprogram.pyAdding -F (or --onefile) parameter will pack everything into single "exe".
pyinstaller -F --paths=<your_path>\Lib\site-packages yourprogram.pyrunning into "ImportError" you might consider side-packages.
pip install pynput==1.6.8still runing in Import-Erorr - try to downgrade pyinstaller - see Getting error when using pynput with pyinstaller
For a more detailed walkthrough, see the manual.
You can use py2exe as already answered and use Cython to convert your key .py files in .pyc, C compiled files, like .dll in Windows and .so on Linux.
It is much harder to revert than common .pyo and .pyc files (and also gain in performance!).