Hello,
I want to completely disable the tkinter module and I tried doing the recommended way:
from PyInstaller.compat import modname_tkinter
excludedimports=[modname_tkinter]
but as stated in the documentation as long as someone else (including Pyinstaller's built-in hooks) imports this module it will not be excluded from the build.
So now I want to disable the pyi_rth__tkinter.py hook because I saw other modules like PIL that use tkinter. Is this possible?
I'm not aware of any way to disable the runtime hooks. But to reach your aim to exclude tkinter: The way for this is to pass --exclude-module on the command line. This should overwrite any imports within your program.
Thanks, this worked for me, but it's strange that excludedimports didn't. Don't you think?
but it's strange that excludedimports didn't. Don't you think?
No, this is how it is expected to work. Imagine your application relies on tkinter and the hook of some package you are using is excluding tkinter (e.g. since it is only optional for this package). Would you want tkinter to be excluded by the hook?
Ok, I'll accept that.
And I must correct myself about fixing my problem. Build procedure with pyinstaller is successful and when I execute my exe on the build machine - it's ok. When I package it and install on a target machine I get the same error again:
File "site-packages\PyInstaller\loader\rthooks\pyi_rth__tkinter.py", line 28, in <module>
FileNotFoundError: Tcl data directory "C:\XXXX\tcl" not found.
Failed to execute script pyi_rth__tkinter
Which means someone is still importing tkinter after all?
Most helpful comment
Ok, I'll accept that.
And I must correct myself about fixing my problem. Build procedure with
pyinstalleris successful and when I execute myexeon the build machine - it's ok. When I package it and install on a target machine I get the same error again:File "site-packages\PyInstaller\loader\rthooks\pyi_rth__tkinter.py", line 28, in <module> FileNotFoundError: Tcl data directory "C:\XXXX\tcl" not found. Failed to execute script pyi_rth__tkinterWhich means someone is still importing
tkinterafter all?