Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14185

Issue while trying to open a Pyinstaller made .exe of a project that uses Tkinter

$
0
0

Essentially, I'm endeavoring to develop an application using Tkinter GUI and several other libraries. The aim is to eventually publish the app on GitHub, allowing my classmates to download and test it, as it's a college assignment. To achieve this, I'm utilizing PyInstaller.

Within my project, main.py serves as the entry point for the application. I invoked PyInstaller with the following command:

pyinstaller --onefile main.py

The process appears to run smoothly, generating the build and dist directories without any issues.

However, I encounter an anomaly. When I execute dist/main.exe via the VSCode terminal, the application runs as expected. But, if I attempt to open it by double-clicking the .exe file, I encounter the following error:

Traceback (most recent call last):  File "main.py", line 4, in <module>  File "app.py", line 21, in __init__  File "app.py", line 28, in entry_show  File "Frames\intro.py", line 8, in __init__  File "Frames\intro.py", line 13, in create_widgets  File "PIL\Image.py", line 3247, in open FileNotFoundError: [Errno 2] No such file or directory: 'FuelTrackRootTitle.png' [1856] Failed to execute script 'main' due to an unhandled exception!

Initially, when I encountered this traceback, the image files I used were located within a folder inside the project directory where I ran the PyInstaller command. Therefore, I don't believe the issue lies in the image files being located elsewhere.

Note that i am using relative paths for every file.

the file where i get the errors from is the following:

    import tkinter as tk    from tkinter import ttk    from PIL import Image, ImageTk      class IntroFrame(tk.Frame):    def __init__(self, parent):        super().__init__(parent, width=500, height=600, background='white')        self.create_widgets()    def create_widgets(self): # Agrega el logo, titulo y el texto de creador a la intro        # Titulo        title_image = Image.open("FuelTrackRootTitle.png")        title_image_tk = ImageTk.PhotoImage(title_image)        titulito = ttk.Label(self, image=title_image_tk, background='white')        titulito.image = title_image_tk        titulito.place(relx=0.5, rely=0.7, anchor='center')        # Logo        icon_image = Image.open("FuelTrackIconImage.png").resize((300,300))        icon_image_tk = ImageTk.PhotoImage(icon_image)        logo = ttk.Label(self, image=icon_image_tk, background='white')        logo.image = icon_image_tk        logo.place(relx=0.5, rely=0.36, anchor='center')

at this point i have just tried putting the .png files outside the images folder and at the same level as my main.py inside the project, also tried one solution involving the modules sys and os, but none of these things have worked for me.

if anybody can help me with this issue would help me so much.

Thanks in advance :).


Viewing all articles
Browse latest Browse all 14185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>