From a command prompt on Windows 11 with Python 3.8.10 I run the following pyinstaller command:
pyinstaller --onefile --windowed --add-data "solarpic.gif;." scratch.py
solarpic.gif
is in the same folder as scratch.py
, but I get an exception that reads:
Traceback (most recent call last):
File "scratch.py", line 7, in <module>
File "PIL\Image.py", line 3227, in open
FileNotFoundError: [Errno 2] No such file or directory:
'solarpic.gif'
This is the code:
from tkinter import *
from PIL import ImageTk, Image
root=Tk()
picframe = LabelFrame(root)
picframe.grid(column=0, row=0, padx=10,
pady=10,sticky=NSEW)
photo_image = Image.open('solarpic.gif')
img1 = photo_image.resize((600, 200))
photo_image = ImageTk.PhotoImage(img1)
piclabel = Label(picframe, image=photo_image)
piclabel.place(x=10,y=10)
piclabel.pack()
root.mainloop()
I've tried:
--add-data "solarpic.gif;."
--add-data "solarpic.gif;.gif"
--add-data "solarpic.gif;solarpic.gif"