Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with cx_Freeze
#1
Exclamation 
Hi! Smile
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 :

[Image: 144864112_122495319746188_54165558793253...e=6039D6D6]

Line 1357 is :
fen = Tk()
(I imported tkinter)

• Why do I have this error ? How to fix it ?
Reply
#2
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
mederic39 likes this post
Reply
#3
Thanks for your reply...
But I don't use "tix"... Snooty
So this is not the problem.
Reply
#4
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]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with cx_freeze app only on one pc floatingshed 0 1,796 Mar-19-2021, 05:19 PM
Last Post: floatingshed
  cx_freeze frozen executive introduces WinError 10049 KipCarter 3 3,170 Jan-14-2020, 02:34 PM
Last Post: KipCarter
  Python 3.6 Alternatives to Cx_Freeze KipCarter 5 5,037 Jan-14-2020, 11:51 AM
Last Post: KipCarter
  cx_freeze exe does not work? Skycoder 4 6,353 Jan-13-2020, 06:50 PM
Last Post: KipCarter
  How to get cx_Freeze to make folders mad_accountant 0 3,091 Nov-24-2019, 02:22 PM
Last Post: mad_accountant
  cx_freeze setup.py error: No module __SNMP-FRAMEWORK-MIB nacho 8 9,014 Jul-26-2019, 09:33 PM
Last Post: njmatt415
  Error in build using cx_freeze with psychopy based animation olivyac 0 2,913 Sep-19-2017, 07:55 PM
Last Post: olivyac

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020