+ 1

ModuleNotFoundError: No module named 'PIL'

I convert .py to .exe using this command -> pyinstaller --onefile -w file.py After i launch file.exe i get error "Failed to execute script 'file' due to unhandled exception: No module named 'PIL' ", Traceback (most recent call last): File "file.py", line 2, in <module> ModuleNotFoundError: No module named 'PIL' I have reinstalled Pillow 2 times, didnt help Code: from tkinter import * from PIL import ImageTk, Image root=Tk() root.geometry('700x600') path='C:\\Users\\user\\OneDrive\\Đ Đ°Đ±ĐŸŃ‡ĐžĐč ŃŃ‚ĐŸĐ»\\Python + Setup master\\Python\\anchor.PNG' img=ImageTk.PhotoImage(Image.open(path)) lab=Label(root, image=img) lab.pack() root.mainloop(

14th Apr 2022, 9:22 AM
Artur
Artur - avatar
10 Answers
+ 1
Have you ran the code in an interpreter to see if it actually works?
14th Apr 2022, 9:25 AM
Slick
Slick - avatar
+ 1
is there any other way to make .py tp .exe without pyinstaller? Somewhy pyinstaller throws error to any code which has "match: case" or PIL in it ( atleast for me)
14th Apr 2022, 11:56 AM
Artur
Artur - avatar
0
Yeah, it does.
14th Apr 2022, 9:46 AM
Artur
Artur - avatar
0
than it's something with pyinstaller. Just run your codes from the command prompt or learn how to write a short script that will run the code when you double click the icon.
14th Apr 2022, 11:09 AM
Slick
Slick - avatar
0
I do .exe file so i can turn it to setup using another program. Btw pyinstaller works fine if programs is not using any images
14th Apr 2022, 11:16 AM
Artur
Artur - avatar
0
I've used it before, it usually works fine. Not sure about the reasoning though. Have you checked out pyqt5 framework? Pretty simple if you're comfortable with tkinter building. It's all the same with frames within frames within the main window. And the labels and buttons and such can be coded ao easily. I think it has it's own multi platform builder too
14th Apr 2022, 11:19 AM
Slick
Slick - avatar
0
I've heard about pyqt5, but haven't tried it, decided to learn tkinter first
14th Apr 2022, 11:27 AM
Artur
Artur - avatar
0
[SOLVED] If we use auto-py-to-exe everything works, but file size is huge ( for example, this litlle code to display 1 pic takes 70 megabytes)
14th Apr 2022, 12:45 PM
Artur
Artur - avatar
0
Artur For Your Information auto-py-to-exe executes PyInstaller command for the conversion, it only provides a gui window to speed out the process and make it easier to add information related to software like version history, files, etc. So the problem was either in your command or your python version or your code
14th Apr 2022, 2:20 PM
AKSHAY🇼🇳
AKSHAY🇼🇳 - avatar
0
Its kind of weird, commands executed by auto-py-exe and pyinstaller are the same, yet pyinstaller throws error and auto-py-exe works fine
14th Apr 2022, 2:23 PM
Artur
Artur - avatar