0

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")]
      )
TheLizzard
  • 7,248
  • 2
  • 11
  • 31

2 Answers2

1

Below is not a real solution. Only first aid.

In your environment's Bootstrap folder (site-packages\ttkbootstrap\localization), Please rewrite msgcat.py as follows.

from ttkbootstrap.window import get_default_root


class MessageCatalog:
    @staticmethod

    def translate(src):
        return src

    @staticmethod
    def locale(newlocale=None):
        return newlocale

    @staticmethod
    def preferences():
        return []

    @staticmethod
    def load(dirname):
        return 0

    @staticmethod
    def set(locale, src, translated=None):
        pass

    @staticmethod
    def set_many(locale, *args):
        return 1

    @staticmethod
    def max(*src):
        return 1

This operation has the side effect of disabling the ability to switch languages.

市川 泉
  • 11
  • 1
1

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.