How to turn your Python scripts into standalone executables
Packaging your Python program as an executable allows users to run it without installing Python or dependencies. This is useful for distributing tools to non‑technical users or deploying applications on systems where Python is not available.
PyInstaller is the most common tool for creating executables.
pip install pyinstaller
pyinstaller myscript.py
This generates a dist/ folder containing the executable.
Bundle everything into a single file:
pyinstaller --onefile myscript.py
pyinstaller --onefile --icon=app.ico myscript.py
If your program uses images, data files, or templates, you must include them manually:
pyinstaller --onefile --add-data "data.json;." myscript.py
PyInstaller generates a .spec file that you can edit to customize the build process. This is useful for complex applications with multiple resources.
Now that you can create executables, you're ready to explore how to deploy Python applications in Lesson 22: Deploying Python Applications.
← Back to Lesson Index