Python Forum
Pillow on windows - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pillow on windows (/thread-28672.html)



Pillow on windows - TamP - Jul-29-2020

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


RE: Pillow on windows - buran - Jul-29-2020

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?


RE: Pillow on windows - TamP - Jul-29-2020

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