I am trying to create bundle app of my project for MacOS using PyInstaller 3.4 with Python 3.6.8 (not brew, installed from python.org). For the first time running of application yielded the error:

[2195] Failed to execute script pyi_rth__tkinter

I have found a solution to this problem on https://github.com/pyinstaller/pyinstaller/issues/3753#issuecomment-432464838. After that running of AppName.app/Contents/MacOS/AppName goes without any error. But if I try to run AppName.app, it gives:

  File "tkinter/__init__.py", line 2023, in __init__
_tkinter.TclError: invalid command name "msgcat::mc"

To ensure that the project code or manually created spec-file for PyInstaller are not a problem, I wrote a simple script:

import sys
import logging
from pathlib import Path
import tkinter as tk

logging.basicConfig(
    filename=Path('~/Desktop/pyapp.log').expanduser()
)
logger = logging.getLogger()

try:
    tk._test()
except Exception as e:
    logger.exception(e)
finally:
    sys.exit()

Created bundle with pyinstaller main.py --windowed and it behaves the same. Content of pyapp.log after running dist/main.app:

ERROR:root:invalid command name "msgcat::mc"
Traceback (most recent call last):
  File "main.py", line 12, in <module>
  File "tkinter/__init__.py", line 3988, in _test
  File "tkinter/__init__.py", line 2023, in __init__
_tkinter.TclError: invalid command name "msgcat::mc"

0 Answers