Search code examples
pythontkintercx-freezettkbootstrap

Cx_freeze converted executable is not working for ttkbootstrap scripts


After converting my ttkbootstrap project file into exe by using cx_freeze.

When I run the executable file. I get this error and my program does not execute.

  File "C:\Users\KANWAR\AppData\Local\Programs\Python\Python310\Lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 120, in run
    module_init.run(name + "__main__")
  File "C:\Users\KANWAR\AppData\Local\Programs\Python\Python310\Lib\site-packages\cx_Freeze\initscripts\Console.py", line 16, in run
    exec(code, module_main.__dict__)
  File "main.py", line 207, in <module>
  File "C:\Users\KANWAR\AppData\Local\Programs\Python\Python310\lib\site-packages\ttkbootstrap\window.py", line 273, in __init__
    self._style = Style(themename)
  File "C:\Users\KANWAR\AppData\Local\Programs\Python\Python310\lib\site-packages\ttkbootstrap\style.py", line 488, in __init__
    localization.initialize_localities()
  File "C:\Users\KANWAR\AppData\Local\Programs\Python\Python310\lib\site-packages\ttkbootstrap\localization\msgs.py", line 9, in initialize_localities
    m.initialize()
  File "C:\Users\KANWAR\AppData\Local\Programs\Python\Python310\lib\site-packages\ttkbootstrap\localization\msgs.py", line 27, in initialize
    MessageCatalog.set_many(self.locale, *messages)
  File "C:\Users\KANWAR\AppData\Local\Programs\Python\Python310\lib\site-packages\ttkbootstrap\localization\msgcat.py", line 142, in set_many
    return int(root.tk.eval(out))
_tkinter.TclError: invalid command name "::msgcat::mcmset"

In my script I had included following library files.

from ttkbootstrap import *
from ttkbootstrap.constants import *
from ttkbootstrap.dialogs.dialogs import Messagebox

I'm facing this issue everytime. Please is there any solution for this.

Here's my setup.py

from cx_Freeze import setup, Executable
import sys

base = None
if (sys.platform == "win32"):
    base = "Win32GUI"    # Tells the build script to hide the console.

setup(name = "e_mail",
      version = "0.1",
      description = 'PURF BY KANWAR ADNAN',
      executables = [Executable(r"main.py")]
      )

Solution

  • Well, I just installed auto-py-to-exe and converted my script into exe without any problems.

    Also, I used the virtual environment term. I installed virtualenv and made a virtual environment and that helped me reducing 450+ MBs of size my application.

    Because auto-py-to-exe includes almost all the libraries in the python lib.