Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem in making an exe file using Pyinstaller (file made using tkinter and Custom tkinter)

I am trying to make a small application for data entry using tkinter and custom tkinter. The code runs fine in python and I made the exe file of it using pyinstaller --onefile --noconsole try45.py

But on running the exe file it gives error labelled as "Unhandled exception in script". Details of it are attached as below,

I have also attached the image of the error. The first two lines of it say "Failed to execute script 'try45' due to unhandled exception: [Errno 2] No such file or directory: 'C:\Users\Farzan Bashir\AppData\Local\Temp\_MEI127522\customtkinter\assets\themes\blue.json"

and the details in next lines are,

Traceback (most recent call last): File "try45.py", line 2, in File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "customtkinter_init.py", line 3, in File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "customtkinter\widgets\customtkinter_input_dialog.py", line 4, in File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "customtkinter\widgets\customtkinter_label.py", line 4, in File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "customtkinter\widgets\customtkinter_tk.py", line 9, in File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "customtkinter\customtkinter_theme_manager.py", line 83, in File "customtkinter\customtkinter_theme_manager.py", line 16, in load_theme FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Farzan Bashir\AppData\Local\Temp\_MEI44122\customtkinter\assets\themes\blue.json'

PLEASE HELP !!!

like image 303
Muhammad Farzan Bashir Avatar asked Oct 20 '25 11:10

Muhammad Farzan Bashir


2 Answers

had the same problem, adding custom tkinter folder data in site-packages folder into console command solved it, here:

pyinstaller --noconfirm --onefile --windowed --add-data "C:\Users\(your pc name)\AppData\Local\Programs\Python\(your python version that has custom tkinter)\Lib\site-packages\customtkinter;customtkinter/"  "<Path to Python Script>"
like image 68
noor osama Avatar answered Oct 23 '25 00:10

noor osama


On your terminal navigate to your directory that contains your GUI using cd<path> Then use this exact command to get your .exe

pyinstaller -F BooyooToDo.py --collect-all customtkinter -w

like image 36
Kirubel Fekadu Avatar answered Oct 23 '25 02:10

Kirubel Fekadu