Search code examples
pythonnumpyunicodeunicode-escapes

Can't read a jpeg with skimage


I'm trying to run this code but it does not work. google- I look, but I have not found the answer, but I look in vain here

from skimage import io
photo = io.imread('C:\Users\comp\Desktop\Urban.jpg')
type(photo)

The answer should be as follows: numpy.ndarray

Error:

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

Solution

  • instead of single slash use double slash

    from skimage import io
    photo = io.imread('C:\\Users\\comp\\Desktop\\Urban.jpg')
    type(photo)