Overview
Platzi Viewer can be compiled into standalone Windows executables using PyInstaller. Two build scripts are provided:- Desktop Application (
build_desktop_exe.ps1) - Single-file.exewith native window - Portable Bundle (
build_portable_exe.ps1) - Directory-based bundle that opens in browser
Prerequisites
- Windows 10/11
- Python 3.8+ with
pip - PowerShell 5.1 or higher
- PyInstaller 6.2.0+
Installation
Build Types
Desktop Application (Recommended)
Single-file executable with native window - Best user experience, no browser required.Portable Bundle
Directory-based bundle with separate executable - Opens in default browser, includes all resources.Build Scripts
Desktop EXE Script (build_desktop_exe.ps1)
Features:
- Single-file executable (
--onefile) - Windowed mode (
--windowed) - No console window - Embeds all resources using
--add-data - Auto-detects UI backend (pywebview or PyQt6)
- Optional code signing support
Portable EXE Script (build_portable_exe.ps1)
Features:
- Directory-based bundle (
--onedir) - Console-visible for debugging
- Copies resources post-build
- Includes data files (cache, progress)
- Embeds service account if present
Build Process
Both scripts follow a similar workflow:Dependency validation
Verifies required Python packages are installed:
requestsgoogle.oauth2.service_accountgoogleapiclient.discoverygoogle.auth.transport.requests
webview(pywebview) ORPyQt6.QtWebEngineWidgets(PyQt6)
PyInstaller Configuration
Hidden Imports
Both scripts specify hidden imports to ensure all dependencies are included:Data Files (Desktop Build)
Resources are embedded using--add-data:
Distribution
Desktop Application
Single file to distribute:- Windows 10/11 (64-bit)
- No Python installation needed
- No browser required (uses native window)
- Run
PlatziViewerDesktop.exe - Creates
PlatziData/directory alongside executable - Looks for
service_account.jsonin same directory
Portable Bundle
Entire directory to distribute:- Windows 10/11 (64-bit)
- No Python installation needed
- Modern web browser (Chrome, Edge, Firefox)
- Extract entire
PlatziViewer/directory - Run
PlatziViewer.exe - Opens in default browser
Code Signing (Optional)
The desktop build script supports automatic code signing to avoid Windows SmartScreen warnings.Setup Certificate
Obtain code signing certificate
Purchase from a trusted CA (DigiCert, Sectigo, etc.) or use self-signed for testing.
Signing Command (build_desktop_exe.ps1:104-108)
Troubleshooting
Build Fails: Missing Dependencies
Build Fails: Missing UI Backend (Desktop)
Executable Won’t Start
Windows SmartScreen:- Click “More info” → “Run anyway”
- OR sign the executable (see Code Signing)
- Ensure all files in
dist/PlatziViewer/_internal/are present (portable) - Try running from command line to see error messages
Service Account Not Found
Desktop EXE:service_account.json in same directory as .exe:
service_account.json present:
Large Executable Size
Desktop EXE (~150 MB):- Includes Python runtime + PyQt6/pywebview
- Normal for single-file bundles
- Use portable bundle instead (distributes size across multiple files)
- Use pywebview instead of PyQt6 (smaller)
- Exclude unnecessary files with
--exclude-module
Build Script Permission Denied
Clean Build Issues
Force clean all build artifacts:Advanced Configuration
Custom Icon
Replacefavicon.ico before building:
Exclude Development Files
Modify PyInstaller command to exclude:Add Custom Data Files
Desktop build:UPX Compression (Reduce Size)
Install UPX and enable compression:CI/CD Integration
GitHub Actions Example
Comparison
| Feature | Desktop EXE | Portable Bundle |
|---|---|---|
| File Structure | Single .exe | Directory with multiple files |
| Size | ~50-150 MB | ~40-100 MB |
| Startup Time | Fast (2-3s) | Medium (3-5s) |
| User Interface | Native window | Browser window |
| Distribution | 1 file | Zip directory |
| Updates | Replace 1 file | Replace directory |
| Debug Console | Hidden | Visible (shows logs) |
| Credentials | External file | Can be embedded |
| Code Signing | Supported | Not implemented |
Best Practices
Security
- Never commit built executables to version control
- Store credentials separately or encrypt
- Sign executables for production distribution
- Use environment variables for sensitive build options
Testing
- Test on clean Windows installation
- Verify all resources load correctly
- Check antivirus compatibility
- Test without Python installed
Distribution
- Compress with 7-Zip or zip for smaller downloads
- Provide SHA256 checksums
- Include README with setup instructions
- Host on GitHub Releases or CDN
Maintenance
- Keep build scripts in version control
- Document build environment requirements
- Test builds on multiple Windows versions
- Maintain changelog for each build
Next Steps
Desktop Application
Learn about running from source
Docker Deployment
Deploy in containerized environment