Skip to content

Bundle PIL._tkinter_finder so the Linux build doesn't crash on startup (fixes #5) - #6

Merged
ckuma merged 1 commit into
mainfrom
fix/linux-pyinstaller-pil-tkinter
Jun 17, 2026
Merged

Bundle PIL._tkinter_finder so the Linux build doesn't crash on startup (fixes #5)#6
ckuma merged 1 commit into
mainfrom
fix/linux-pyinstaller-pil-tkinter

Conversation

@ckuma

@ckuma ckuma commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Problem

The packaged Linux artifact (v4.1) crashes immediately on launch:

ModuleNotFoundError: No module named 'PIL._tkinter_finder'

(preceded by _tkinter.TclError: invalid command name "PyImagingPhoto"). Running from source works fine, because nothing is frozen there.

Root cause

PIL.ImageTk imports PIL._tkinter_finder at runtime to register Pillow's image objects with the Tcl/Tk interpreter (the PyImagingPhoto command). The first ImageTk call happens at startup when ttkbootstrap draws the combobox arrow asset — so a missing _tkinter_finder is fatal.

PyInstaller only auto-collects that submodule on some versions of pyinstaller / pyinstaller-hooks-contrib. Our CI uses unpinned pip install pyinstaller, so the version present when v4.1 was tagged didn't include it.

Fix

Add --hidden-import "PIL._tkinter_finder" to all three build paths (CI Linux, CI Windows, build_exe.bat) so it is always bundled, independent of the PyInstaller version.

Verification

  • Linux (WSL Ubuntu 24.04) and Windows, fresh PyInstaller 6.21.0 / Pillow 12.2.0: built the frozen probe both ways. The flag reliably includes the module and the ttkbootstrap Combobox -> ImageTk path succeeds. The flag is a no-op where the module is already collected, so there is no risk to platforms that were already working.

Recommended follow-up (not in this PR)

This bug was caused by build-tool version drift. Consider pinning pyinstaller (e.g. pyinstaller==6.21.0) in CI so releases are reproducible and packaging cannot silently regress again.

PIL.ImageTk imports PIL._tkinter_finder at runtime to register Pillow's
image objects with the Tcl/Tk interpreter (the PyImagingPhoto command).
PyInstaller does not reliably collect this submodule across versions, so
the frozen Linux build shipped in v4.1 crashed on startup when ttkbootstrap
drew the combobox arrow asset:

    ModuleNotFoundError: No module named 'PIL._tkinter_finder'

Add it as an explicit --hidden-import on all three build paths (CI Linux,
CI Windows, and build_exe.bat) so it is always bundled regardless of the
PyInstaller version installed at build time.

Fixes #5
@ckuma
ckuma merged commit 6d33e94 into main Jun 17, 2026
5 checks passed
@ckuma
ckuma deleted the fix/linux-pyinstaller-pil-tkinter branch June 17, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant