Cant use image from PIL library

Viewed 33

I'm a new entry in this field. Recently, I started a course and one of the objects is to use image from PIL library. I installed it in my PowerShell terminal using : python3 -m pip install --upgrade pip python3 -m pip install --upgrade Pillow . But when I try to use the library in my Pycharm ide, it does not work. This is the whole code :

from PIL.Image import Image

img = Image.open('.\pozepoc\pikachu.jpg')

print(img)

and i get an error saying

img = Image.open('.\pic\Picture.jpg')

AttributeError: type object 'Image' has no attribute 'open'

also if i use the whole path of the folder of images like

img = Image.open('C:\Users\40729\Desktop\pic\Picture.jpg')

i get this error

img = Image.open('C:\Users\40729\Desktop\pic\Picture.jpg')

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I googled the problem, but I can't find the answer. Can someone explain what I have to do and why it does not work, I m looking for an explanation also because it's my learning journey that I m interested in most. Thank you.

0 Answers
Related