S
S
SS_Maksim2022-01-23 23:09:23
Building projects
SS_Maksim, 2022-01-23 23:09:23

I get an error while building the executable .exe file of python, what's the problem?

After building the python script into an executable exe file and running the exe script, an error occurs:

Traceback (most recent call last):
  File "Logreader_from_SVIRID.py", line 11, in <module>
  File "tkinter\__init__.py", line 4064, in __init__
  File "tkinter\__init__.py", line 4009, in __init__
_tkinter.TclError: couldn't open "apple.png": no such file or directory


At the same time, if I run the code in pycharm, everything works fine. The logo is replaced, there are no errors. The error occurs during build.

In my code, line 11 is causing the error: this line changes the "feather" logo to my "apple.png" in a tkinter GUI application The apple.png file is in the same directory as the python script itself I build the exe file like this way:
photo = PhotoImage(file = 'icon.png')


pyinstaller -F -w -i "C:\Users\Maksim\PycharmProjects\Free_projects\RTC\Logreader_r
elease_23.01.2022\Printer.ico" Logreader.py


"C:\Users\Maksim\PycharmProjects\Free_projects\RTC\Logreader_r
release_23.01.2022\Printer.ico" - absolute path to the icon of the exe file itself, there are no problems with it.

Part of the code (the whole does not fit)
from tkinter import *
import os, fnmatch, time
import shutil
import tkinter.filedialog as fd
from datetime import datetime
window = Tk() # создание главного окна

photo = PhotoImage(file = 'icon.png')               # присвоение переменной реквизиты картинки

window.iconphoto(False, photo)                      # прикрепление картинки иконки главного окна
window.config(bg='gainsboro')                       # изменение фона главного окна
window.title('Logreader from SVIRID')               # назнаие гланого окна
window.geometry('1000x600+80+50')                   # размер главного окна, ширина высота, отступ от левого верхнего угла в пикселях
window.resizable(True, True)

...

window.mainloop()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question