4.6 KiB
4.6 KiB
Building LabelPrinter.exe on Windows
This guide explains how to build a standalone LabelPrinter.exe single-file executable on a Windows machine.
Prerequisites
-
Python 3.10, 3.11, 3.12, or 3.13 - Download from https://www.python.org/
- ⚠️ IMPORTANT: Check "Add Python to PATH" during installation
- ⚠️ Note: Python 3.14+ may have compatibility issues with Kivy 2.2.1
- Verify: Open Command Prompt and type
python --version
-
Git (optional, for cloning the repository)
-
Internet connection - To download dependencies
Quick Start (Using Provided Scripts)
Option 1: Batch Script (Recommended for CMD users)
- Open Command Prompt (cmd.exe)
- Navigate to the project folder:
cd C:\path\to\label_print - Run the build script:
build_windows.bat - Wait 5-15 minutes for the build to complete
- The executable will be in:
dist\LabelPrinter.exe
Option 2: PowerShell Script
- Open PowerShell (as Administrator recommended)
- Navigate to the project folder:
cd C:\path\to\label_print - Allow script execution (if needed):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - Run the build script:
.\build_windows.ps1 - Wait 5-15 minutes for the build to complete
- The executable will be in:
dist\LabelPrinter.exe
Manual Build Steps
If you prefer to run commands manually:
Step 1: Prepare Python Environment
# Upgrade pip, setuptools, and wheel
python -m pip install --upgrade pip setuptools wheel
Step 2: Install Dependencies
# Install required Python packages
pip install python-barcode pillow reportlab kivy==2.2.1 pyinstaller==6.1.0
Step 3: Build the Executable
# Create single-file executable
pyinstaller label_printer_gui.py ^
--onefile ^
--windowed ^
--name=LabelPrinter ^
--distpath=./dist ^
--workpath=./build ^
--hidden-import=kivy ^
--hidden-import=PIL ^
--hidden-import=barcode ^
--hidden-import=reportlab ^
--hidden-import=print_label ^
--hidden-import=print_label_pdf ^
-y
The build process will take 5-15 minutes depending on your PC speed.
Step 4: Test the Executable
# Run the built executable
dist\LabelPrinter.exe
Output
After successful build, you'll have:
dist/
└── LabelPrinter.exe ← Single executable file
Distributing the Executable
You can:
- Copy
LabelPrinter.exeto any Windows PC (no Python needed!) - Share via USB or file transfer
- Create an installer using NSIS or InnoSetup (optional)
- Upload to GitHub Releases for public distribution
Troubleshooting
Error: "Python is not recognized"
- Reinstall Python and check "Add Python to PATH"
- Restart Command Prompt after reinstalling Python
Error: "pip command not found"
- Use
python -m pipinstead ofpip
Build takes too long (>30 minutes)
- Normal for first build - Kivy framework is large
- Subsequent builds will be faster due to caching
- Close other applications to free up RAM
Error: "No module named 'kivy'"
- Make sure dependencies installed correctly:
pip install kivy==2.2.1 - Check internet connection
Python 3.14 Compatibility Issues
If you have Python 3.14 installed and get errors like:
ModuleNotFoundError: No module named 'kivy'ImportError: DLL load failed- PyInstaller compatibility errors
Solution:
- Install Python 3.11, 3.12, or 3.13 instead
- Download from: https://www.python.org/downloads/
- Uninstall Python 3.14 first
- Then use one of the recommended versions
- Make sure all files are in the project folder:
label_printer_gui.pyprint_label.pyprint_label_pdf.py
- Antivirus might be blocking it - check security software
Build Time Reference
- First build: 10-15 minutes (downloading dependencies)
- Subsequent builds: 5-10 minutes (cached dependencies)
Advanced Options
Reduce Build Time
pyinstaller label_printer_gui.py --onefile --windowed --name=LabelPrinter -y
Add Icon to Executable
pyinstaller label_printer_gui.py --onefile --windowed --name=LabelPrinter --icon=path\to\icon.ico -y
Faster: Use --onedir (Directory) instead of --onefile
pyinstaller label_printer_gui.py --onedir --windowed --name=LabelPrinter -y
# Builds in ~3-5 minutes, but creates a folder instead of single file
Support
If you encounter issues:
- Check the error message carefully
- Make sure Python 3.10+ is installed
- Verify all dependencies:
pip list - Check internet connection
- Try again with a fresh Command Prompt window