Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pillow on windows
#1
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
Reply
#2
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?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
You were correct of course.
I uninstalled python completely and reinstalled
All is well
Thanks
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020