It try to load tix module,so i would try Pyinstaller instead of troubleshoot on this.
Quick test.
Usage
Quick test.
# tk_test.py import tkinter as tk class App(tk.Tk): def __init__(self): super().__init__() self.var = tk.StringVar() self.var.trace("w", self.show_message) self.entry = tk.Entry(self, textvariable=self.var) self.btn = tk.Button(self, text="Clear", command=lambda: self.var.set("")) self.label = tk.Label(self) self.entry.pack() self.btn.pack() self.label.pack() def show_message(self, *args): value = self.var.get() text = f"Hello, {value}!" if value else "" self.label.config(text=text) if __name__ == "__main__": app = App() app.mainloop()Using Python 3.9.1 and Pyinstaller 4.2(
pip install pyinstaller
).C:\code\tk_exe λ python -V Python 3.9.1 C:\code\tk_exe λ pyinstaller --version 4.2Icon here call it
idea.ico
Usage
pyinstaller --onefile --windowed --icon=idea.ico tk_test.py
C:\code\tk_exe λ pyinstaller --onefile --windowed --icon=idea.ico tk_test.py 66 INFO: PyInstaller: 4.2 67 INFO: Python: 3.9.1 68 INFO: Platform: Windows-10-10.0.19041-SP0 71 INFO: wrote C:\code\tk_exe\tk_test.spec ..... 9558 INFO: Appending archive to EXE C:\code\tk_exe\dist\tk_test.exe 9571 INFO: Building EXE from EXE-00.toc completed successfully.In
dist
folder tk_test.exe
.