pythonpython-imaging-library

AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'


Here's some sample code:

import tkinter as tk
from PIL import Image, ImageTk

window = tk.Tk()

image = Image.open(r"VC.png")
image = image.resize((20, 20), Image.ANTIALIAS)

tk_image = ImageTk.PhotoImage(image)

image_label = tk.Label(window, image=tk_image)
image_label.pack()

window.mainloop()

Here's the error:

Traceback (most recent call last):
  File "<module1>", line 19, in <module>
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Solution

  • The problem is with Pillow 10.0.

    Trying to uninstall Pillow might give some errors.

    Just put this in cmd:

    pip install Pillow==9.5.0