So I am using customtkinter for a small project and I made an executable file using pyinstaller. When I run the exe file I get the following error.
Traceback (most recent call last):
File "main.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "src\app\frontend\main_ui.py", line 250, in <module>
File "src\app\frontend\main_ui.py", line 215, in __init__
File "customtkinter\windows\ctk_tk.py", line 228, in wm_iconbitmap
File "tkinter\__init__.py", line 2138, in wm_iconbitmap
_tkinter.TclError: bitmap "data\images\valeo.ico" not defined
I tried a few solutions from stackoverflow, but it doesn't seem to work, apparently this is an issue in Linux but I am using Windows 11.
I would appreciate it if someone helps me in this matter.
Thank you.
The error occurs because the
.exe
file either doesn't contain the filevaleo.ico
or the file can't be accessed. Make sure that the.exe
contains the icon file. If it does, and you still get the error, in your.py
file, you need to access the icon file in a different way. Example code:When
Pyinstaller
is run using theonefile
option, a temporary folder structure is created. The path to this structure in stored insys._MEIPASS
. So, we append the folder structure path to the path of our image file.