1

I had a error I can't do anything with. when I convert python to exe and follow the debug using --debug I saw this error

ModuleNotFoundError: No module named 'PIL'

with another error said

FileNotFoundError: [Errno 2] No such file or directory: 'sos.gif' 

Although I installed pillow

I appreciate your time

  • Maybe something went wrong when you installed pillow you can try: pip uninstall pillow then try: pip install pillow. – RedRaptor Apr 24 '22 at 05:19

3 Answers3

0

Are you in a virtual environment? I don’t know how PyInstaller works in virtual environments, but maybe thats whats causing the issue. If so, try installing the packages your file needs globally, and then convert the file to .exe outside of the virtual environment.

montw
  • 85
  • 10
0

Please install the third-party modules that the source file imports and modify .spec file to link data files after running pyinstaller [option] -o [file].

Yuchen Ren
  • 287
  • 5
  • 13
0

Thanks to everyone who tried to answer, I found out that the error was in the incorrect installation of pyinstaller. I reinstalled it. Then I replace the code from

image = ImageTk.PhotoImage(Image.open("sos.gif"))

TO

image = ImageTk.PhotoImage(Image.open(r'C:\Users\****\Desktop\sos.gif'))

after these steps it's working because when converted to exe program misses the image. to avoid this you should write where this image