The problem
Hard-coded relative paths often break after packaging. Onefile also extracts files to a temp directory, so your runtime path changes.
The clean pattern
- Include assets using PyInstaller’s data-file options.
- Resolve the runtime base directory in code and build paths from it.
What to bundle
- UI assets (icons, images)
- Config templates
- ML models
- Default data files
Tip: In PyInstaller GUI, keep assets grouped and add them as a folder to avoid missing individual files later.