KeKe
KeKe

Reputation: 187

How can I load an image using Python Pillow?

I load an image this way:

from PIL import Image
im = Image.open('test.png')

gives me the following error:

IOError: [Errno 2] No such file or directory: 'test.png'

I have saved the image 'test.png' on the desktop.

So where should I save the image?

Upvotes: 10

Views: 22761

Answers (1)

pranavrao1
pranavrao1

Reputation: 1617

You need to give the directory where the file is located. So if you put in desktop it should go something like this:

Image.open('C:\Users\$(your_user_name)\Desktop\test.png')

or move the file "test.png" to folder where your script is.

Upvotes: 23

Related Questions