Guides · Product
How to package a Python desktop app into a Windows installer.
Turn a Python script into a Windows app: PyInstaller, Inno Setup, per-user installs, bundling fonts and models, testing on a clean PC.
Key takeaways
- Package in two steps: bundle the app into an executable, then wrap it in an installer.
- Test on a clean Windows machine, because your development PC hides missing files.
- Bundle everything the app needs, such as fonts, models and data files, and find them through the right paths.
- Unsigned executables may trigger SmartScreen or antivirus warnings, so plan for it.
Step 1: bundle with PyInstaller
PyInstaller collects your script, the Python interpreter and its dependencies into a folder or a single file.
pip install pyinstaller
pyinstaller --noconfirm --windowed --name MyApp main.py
--windowed hides the console for GUI apps. The output appears in dist/MyApp/. The folder mode (--onedir) starts faster and is easier to debug than --onefile, which unpacks to a temporary directory on every launch.
Use a .spec file for repeatable builds and to add data files and hidden imports.
Data files and paths
Files that live next to your code, such as icons, fonts or models, are not included automatically. Add them in the spec file or with --add-data. At runtime, find them relative to the bundle:
import sys, os
def resource_path(name):
base = getattr(sys, "_MEIPASS", os.path.dirname(__file__))
return os.path.join(base, name)
Never write user data into the app folder. Use the user's app data directory instead.
Fonts and encodings
If your app renders text in other scripts, bundle a font that supports them and read and write files as UTF-8. A common failure is empty boxes where text should be, because the target PC lacks the font or the file was saved in another encoding.
Large models and downloads
If the app needs a large model, decide whether to bundle it or download on first run. Bundling makes the installer huge. Downloading needs internet once, and the app must handle failures and resume.
Step 2: build an installer with Inno Setup
Inno Setup is a free tool that creates a normal Windows setup program from a script:
[Setup]
AppName=MyApp
AppVersion=1.0.0
DefaultDirName={autopf}\MyApp
PrivilegesRequired=lowest
OutputBaseFilename=MyApp-Setup-1.0.0
[Files]
Source: "dist\MyApp\*"; DestDir: "{app}"; Flags: recursesubdirs
[Icons]
Name: "{autoprograms}\MyApp"; Filename: "{app}\MyApp.exe"
PrivilegesRequired=lowest makes a per-user installation that does not need an administrator password, which is friendlier for most users.
Uninstall and upgrade
Inno Setup creates an uninstaller. Use a stable AppId so a new version upgrades the old one instead of installing beside it. Do not delete user data on uninstall without asking.
Test on a clean machine
Use a virtual machine or a spare PC with no Python and no development tools. Check:
- The app starts and finds all its files.
- It works with a username that has spaces or non-English characters.
- It handles a missing internet connection politely.
- Install, upgrade and uninstall all work.
- It runs under a standard user account.
Warnings from Windows and antivirus
New, unsigned executables can trigger SmartScreen's "Windows protected your PC" or false positives from antivirus programs. Code signing helps, but certificates cost money. Meanwhile, publish the checksum and explain the warning to users. See shipping an installer without a code-signing certificate and verifying with SHA-256.
Release checklist
- Increase the version number.
- Build and test the executable.
- Build the installer.
- Compute the SHA-256 and publish it with the download.
- Test the download on a clean machine.
- Update release notes and the product page.
Frequently asked questions
Is one file better than a folder?
The one-file build is neat to share but starts slower and is harder to debug. Use an installer around the folder build for a polished result.
Can I package for macOS or Linux too?
Yes, with different tools, and you must build on each platform.
Why is the installer so large?
Python and libraries such as machine-learning packages are big. Remove unused dependencies and exclude modules you do not need.
TurboGet ships as a Windows installer built from Python.
See TurboGet