Python Forum

Full Version: Pillow on windows
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am running python 32bit 3.8.4 on Windows 10
I installed pillow with, pip install Pillow but python does not like this
and returns PIL not found

from tkinter import *

from PIL import ImageTk,Image
#Tried this as well
#from pillow.Image import core as _imaging

root = Tk()
num = 0
canvas = Canvas(root, width = 1920, height = 1080)
img_0 = ImageTk.PhotoImage(Image.open("Photo (1).jpg"))  
img_1 = ImageTk.PhotoImage(Image.open("Photo (50).jpg)"))  

def task():
    global num 
    canvas.delete("all")
    canvas.create_text(20,20, text="loop " + str(num))
    if num %2 ==  0:
        canvas.create_image(20, 40, anchor=NW, image=img_0)              
    if num %2 == 1:
        canvas.create_image(20, 40, anchor=NW, image=img_1)        
    num += 1               
    root.after(2000, task)  # reschedule event in 2 seconds   
canvas.pack()
canvas.create_text(20,20, text="hello")

root.after(2000, task)
root.mainloop()
Pillow documentation suggests I should use
from pillow.Image import core as _imaging
but what syntax should I use in this line ?
img_0 = ImageTk.PhotoImage(Image.open("Photo (1).jpg"))
Any help appreciated
your code works (i.e. no error, but I am not sure how you expect that n will change), so there is problem with Pillow installation. Is it possible that you have more than one python installation?
You were correct of course.
I uninstalled python completely and reinstalled
All is well
Thanks