Search code examples
matplotlibjupyter-notebookimread

importing a picture using imread


i'm trying to run this code in a jupyter notebook but i'm getting an error:

from matplotlib.image import imread
test = imread("data/photo1.jpg")
print(type(test))

error:

   1411         try:
-> 1412             from PIL import Image
   1413         except ImportError:

ModuleNotFoundError: No module named 'PIL'

Does anyone know why I'm getting this? I'm importing imread, so no idea where PIL comes into it.

Thanks.


Solution

  • I found the mistake. imread can only handle png's by default. After installing "pillow", I was able to handle the jpg using the above code! Hope this post helps someone else encountering the same issue!