pyinstaller can't find package Tix

1.1k Views Asked by At

I am trying to create an executable with pyinstaller for a python script with tix from tkinter. The following script also demonstrates the error:

from tkinter import * 
from tkinter import tix

root = tix.Tk()
root.mainloop()

I have Python 3.9 installed and the script runs fine and works as intended but after using pyinstaller to create an executable, the .exe file fails to run because it can't find the package Tix.

One of the solutions mentioned here which is to copy the C:\Python39\tcl\tix8.4.3 folder to the dist directory for the executable worked for me. The executable runs as intended after copying the folder, but I would like to package the script into one exe without needing to supply the tix8.4.3 folder.

Is there anyway to package the tix folder when building the executable with pyinstaller?

2

There are 2 best solutions below

0
acw1668 On BEST ANSWER

It works for me using below command to generate the executable:

pyinstaller -F --add-data C:\Python38\tcl\tix8.4.3;tcl\tix8.4.3 main.py

Note that I use PyInstaller 4.7 and Python 3.8.12 under Windows 7.

1
Thyrus On

you have error in code:

from tkinter import * 
from tkinter import tix

root = tix.Tk() # Here it was TK
root.mainloop()