0
votes

I am trying to make an executable for my Python script and the only problem is getting the image file to work with it. I have tried everything I could online including changing the file from .png to .gif (including in the spec and source code), using --add-file, using auto-py-to-exe, but really nothing has been working. The code that is messing up the .exe is the following:

background_image = tkinter.PhotoImage(file='usf.gif')

I had it in .png but I saw online that it can work better with .gif, and still it doesn't work. I have it in the /dist/ folder with the executable and it doesn't work. It works perfectly just running the script in Python, and the executable works when I remove this line of code from the Python code, but then I don't have an image displaying.

When I run the executable with --debug from pyinstaller, it says "Tkinter error: Couldn't recognize data in image file" so I know it has to do with the image file in question.

Any help is greatly appreciated.

1
So you renamed the file from a .png to a .gif or you actually converted it (using paint, ect.)? - tgikal

1 Answers

0
votes

I solved it by converting the .png to an actual .gif instead of just renaming the extension.