Bundle PIL._tkinter_finder so the Linux build doesn't crash on startup (fixes #5) - #6
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The packaged Linux artifact (v4.1) crashes immediately on launch:
(preceded by
_tkinter.TclError: invalid command name "PyImagingPhoto"). Running from source works fine, because nothing is frozen there.Root cause
PIL.ImageTkimportsPIL._tkinter_finderat runtime to register Pillow's image objects with the Tcl/Tk interpreter (thePyImagingPhotocommand). The firstImageTkcall happens at startup when ttkbootstrap draws the combobox arrow asset — so a missing_tkinter_finderis fatal.PyInstaller only auto-collects that submodule on some versions of
pyinstaller/pyinstaller-hooks-contrib. Our CI uses unpinnedpip 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
Combobox->ImageTkpath 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.