[Python] AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Discussão em 'Python' iniciado por Stack, Julho 22, 2025.

  1. Stack

    Stack Membro Participativo

    • I am trying to have images in my Tkinter GUI, hence I am using PIL.
    • Image.ANTIALAIS is not working. However, Image.BILINEAR works

    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'

    • I tried reinstalling pip and Pillow. It didn't work.
    • I asked ChatGPT about this, and it advised me to upgrade to Pillow's latest version. I am on the latest version (10.0.0).

    Continue reading...

Compartilhe esta Página