python-packaging
Guide for packaging Python apps with PyInstaller for Windows and macOS
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Guide for packaging Python apps with PyInstaller for Windows and macOS
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | python-packaging |
| description | Guide for packaging Python apps with PyInstaller for Windows and macOS |
Guide for packaging Python applications into professional executable files (.exe, .app) using PyInstaller.
pip install pyinstaller
| Flag | Meaning |
|---|---|
--onefile | Bundle everything into a single file (good for small tools) |
--onedir | Keep folder structure (good for large apps, faster startup) |
--windowed | Hide console window (GUI apps) |
--noconsole | Same as --windowed |
--name "App" | Set output filename |
--icon=icon.ico | Set icon (Windows: .ico, Mac: .icns) |
python -m PyInstaller --onefile --noconsole --name "MyApp" main.py
python -m PyInstaller --onefile --name "MyTool" main.py
--onefile. Use --onedir if avoiding this is priority..ico file.python -m PyInstaller --windowed --noconsole --name "MyApp" main.py
--onefile very well (slow startup). Recommend default (--onedir) or --windowed..app bundle, not a single file.When packaging with --onefile, assets are unpacked to a temp folder _MEIxxxx. Code is needed to find the correct path:
import sys
import os
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
# Usage
icon_path = resource_path("icon.png")
Use --add-data flag:
--add-data "src;dest"--add-data "src:dest"Example:
# Windows
pyinstaller --onefile --add-data "config.json;." main.py
Always optimize requirements.txt before building to reduce exe size.
pip freeze > requirements.txt (Captures all system junk libraries)
List only actually used libraries:
PyQt6>=6.4.0
pandas
openpyxl
pillow
PyInstaller is NOT a Cross-Compiler.
.exe file -> Must build on Windows..app file -> Must build on macOS.Solutions:
pip install -r requirements.txt firstpython main.pyresource_path)dist/ directoryWhen activating this skill, print: "🎯 [SKILL ACTIVATED] python-packaging v1.0.0" "📋 Parameters:" " - Target: [script.py]" " - Mode: [onefile|onedir]" " - OS: [Windows|macOS]" " - Assets: [list_of_included_assets]"
Before running the build command (long process): "I'm about to package [Target] using PyInstaller with options: [Options]. This may take a few minutes. Proceed?"
Best practices for robust Excel data processing with Pandas and OpenPyXL
Git workflow patterns, commit conventions, and edge case handling for Antigravity projects
Best practices and patterns for building robust PyQt6 desktop applications