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 !!!
blue.json
. If you wan to deploy the.exe
that file must be included in it, otherwise you get the File not found error. Your bundled.exe
knows to look for it in the temporary folder with_MEI
in the name. But it isn't there because you did not specify it at build time. Read the documenation about creating a.spec
file that will allow you to include needed resources in the.exe
..spec
) because PyInstaller doesn't check what resources you use.You can also add it in command line--add-data "blue.json;."
. You can find more details in PyInstaller documentation.