Quick Fix:
Run pip install auto-py-to-exe, fire up the GUI with auto-py-to-exe, point it at your script, and hit “Convert.” You’ll get a single .exe that runs anywhere Windows does—no Python install needed.
What's Happening
.exe.
As of 2026, auto-py-to-exe is still the easiest point-and-click option for Windows, while PyInstaller rules the command line for every major OS. Both strip out the “install Python first” step so your app just works on any Windows machine.
Step-by-Step Solution
Path A: GUI with auto-py-to-exe (Windows only)
- Prerequisites
- A working Python 3.11+ install with
pipin your PATH. Confirm it works by typingpython --versionin Command Prompt. - If you’re missing Python, grab the latest 3.11 build from python.org.
- A working Python 3.11+ install with
- Install the wrapper
Open Command Prompt and run:
pip install --upgrade auto-py-to-exe
- Launch the GUI
Still in the same prompt, type:
auto-py-to-exe
A browser window pops up—no fiddling with JSON files or obscure flags. - Configure the build
- Script Location: Browse to your
.pyfile. - Icon (optional): Drop in a
.icofile sized 32×32 or 64×64 pixels. - One Directory: Leave this unchecked if you want a single file instead of a folder full of DLLs.
- Window Based: Pick “Console Based” if your script prints stuff to the screen; choose “Window Based” if it runs silently.
- Advanced: Turn on “UPX compress” to shave a few megabytes off the final size.
- Script Location: Browse to your
- Build
Click “Convert .py to .exe.” The output lands in an
outputfolder right next to your script. - Test
Copy the new
.exeto another Windows box—no Python install required—and double-click. If it runs, you’re golden.
Path B: Command-line with PyInstaller (Windows, macOS, Linux)
- Install PyInstaller
Run:
pip install --upgrade pyinstaller
- Navigate to your script
cd C:\dev\myproject
(Adjust the path to wherever yourmain.pylives.) - Create the bundle
pyinstaller --onefile --windowed --icon=app.ico main.py
--onefilesquashes everything into one neat executable.- Omit
--windowedif you actually want a console window (handy for CLI tools). --iconlets you brand the app with a custom icon.
- Locate the build
Head to the
distfolder and openmain.exeon Windows (or the matching binary on macOS/Linux).
If This Didn’t Work
1. ModuleNotFoundError after conversion
- PyInstaller builds on the exact environment it runs in. If you used a virtual environment, activate it first:
.\venv\Scripts\activate
then rerunpyinstaller. - Some imports hide behind dynamic imports. Tell PyInstaller about them explicitly:
pyinstaller --onefile --hidden-import=module_name main.py
2. Antivirus flags the .exe
- Freshly compiled executables sometimes look suspicious to antivirus engines. Either submit the file to your vendor’s false-positive portal or slap a proper code-signing certificate on it.
3. macOS notarization rejected
- Gatekeeper now demands notarization. After the build, sign the app:
codesign --deep --force --verify --verbose --sign "Developer ID Application: Your Name" dist/main.app
then upload to Apple:xcrun altool --notarize-app --primary-bundle-id com.your.app --username you@email.com --password @keychain:AC_PASSWORD --file dist/main.app
Prevention Tips
| Tip | How It Helps |
|---|---|
| Pin dependency versions | Run pip freeze > requirements.txt so every teammate builds against the exact same stack. |
| Test on a clean VM | Spin up a fresh Windows 10/11 VM and run the .exe inside it. You’ll catch missing runtime errors before anyone else does. |
| Include a README | A plain-text file next to the .exe tells users where to find logs if things go sideways. |
| Automate the build | Set up a GitHub Actions workflow that installs PyInstaller and uploads the artifact every time you push to main. |