Loading image in Python (error)

I want to upload an image, but I get an error message.

My code is:

from PIL import Image
im = Image.open("D:\Python26\PYTHON-PROGRAMME\bild.jpg")
im.show()

I get this error:

Traceback (most recent call last):
  File "D:\Python26\PYTHON-PROGRAMME\00000000000000000", line 2, in <module>
    im = Image.open("D:\Python26\PYTHON-PROGRAMME\bild.jpg")
  File "D:\Python26\lib\site-packages\PIL\Image.py", line 1888, in open
    fp = __builtin__.open(fp, "rb")
IOError: [Errno 22] invalid mode ('rb') or filename: 'D:\\Python26\\PYTHON-PROGRAMME\x08ild.jpg'
+3
source share
1 answer

You need to avoid backslashes:

im = Image.open("D:\\Python26\\PYTHON-PROGRAMME\\bild.jpg")
+9
source

Source: https://habr.com/ru/post/1726905/


All Articles