Hi!
I'm French, sorry for my bad English speaking.
I try to freeze my project in executable file with "cx_Freeze".
I have a file "main.py" and an other "setup.py". I built my file with the "build" command, it works...
Then I double-clicked my ".exe" file to run it, and I have this error :
Line 1357 is :
fen = Tk()
(I imported tkinter)
• Why do I have this error ? How to fix it ?
Pyinstaller is usually a better choice.
tkinter.tix
Quote:Deprecated since version 3.6: This Tk extension is unmaintained and should not be used in new code. Use tkinter.ttk instead.
So do you use tix module in code?
tix and tk are two separate modules.
They have some widgets that have similar names, but they are not interchangeable libraries.
So i have a some old cx_Freeze code,so if not find a module most include it.
# make_exe.py
from cx_Freeze import setup,Executable
import sys
# Replaces commandline arg 'build'
#sys.argv.append("build")
# If need to include/exclude module/packages
includes = ['tix']
excludes = []
packages = []
# Console or Win32GUI
base = None
if sys.platform == "win32":
#base = 'Console'
base = 'Win32GUI'
# Name of file to make ".exe" of
filename = "code.py"
setup(
name = 'Myapp',
version = '0.1',
description = 'Test',
options = {'build_exe': {'excludes':excludes,'packages':packages,'includes':includes}},
executables = [Executable(filename, base=base, icon = None)])
# From command line
#python make_exe.py build
Thanks for your reply...
But I don't use "tix"...

So this is not the problem.
It try to load tix module,so i would try Pyinstaller instead of troubleshoot on this.
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.2
Icon
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
.
![[Image: CDwPRF.png]](https://imagizer.imageshack.com/v2/xq90/923/CDwPRF.png)