Pyinstaller Error – Failed to execute script pyi_rth__tkinter

Operating System: MacOS

Python Version 3.7

Pyinstaller Version 3.4

Pyinstaller can run into some minor issues with MacOS, but solving it might take you longer if you do not get the right guidance. We have kept the solution simple to help you resolve the issue faster.

Below is a snippet of the error

Traceback (most recent call last):
File “PyInstaller/loader/rthooks/pyi_rth__tkinter.py”, line 28, in <module>
FileNotFoundError: Tcl data directory “/var/folders/nl/2wxh3z313l129zpzq2f8ww5m0000gn/T/_MEILUmJRc/tcl” not found.
[2195] Failed to execute script pyi_rth__tkinter

The Error Message basically refers to a file that cannot be found. In most cases, this file may not be necessary to run your application. The only way to know it is to refer to the file pyi_rth_tkinter.py

The file pyi_rth_tkinter.py can be found under the venv folder of your project.

venv/lib/python3.7/site-packages/PyInstaller/loader/rthooks/pyi_rth_tkinter.py

You will find a simple IF Statement that returns an error if a specific file is not found in the tk or tcl directory. You can comment the IF Statement as provided below and try running your PyInstaller code once again.

#if not os.path.isdir(tcldir):
    #raise FileNotFoundError('Tcl data directory "%s" not found.' % (tcldir))
#if not os.path.isdir(tkdir):
    #raise FileNotFoundError('Tk data directory "%s" not found.' % (tkdir))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s