Cannot import scipy.misc.imread

I've seen this problem before with other people, but haven't found a fix.

All I'm trying to do is:

from scipy.misc import imread

and I get

/home1/users/joe.borg/<ipython-input-2-f9d3d927b58f> in <module>()
----> 1 from scipy.misc import imread

/software/Python/272/lib/python2.7/site-packages/scipy/misc/__init__.py in <module>()
     16 try:
     17     from pilutil import *
---> 18     __all__ += pilutil.__all__
     19 except ImportError:
     20     pass

NameError: name 'pilutil' is not defined

But it's fine when I do from pilutil import * on its own (no import error). Even .../site-packages/scipy/misc/pilutil.py exists so I've got no idea why this is failing.


If you have Pillow installed with scipy and it is still giving you error then check your scipy version because it has been removed from scipy since 1.3.0rc1.

rather install scipy 1.1.0 by :

pip install scipy==1.1.0

check https://github.com/scipy/scipy/issues/6212


You might need to install PIL or Pillow.


The method imread in scipy.misc requires the forked package of PIL named Pillow. If you are having problem installing the right version of PIL try using imread in other packages:

from matplotlib.pyplot import imread
im = imread(image.png)

To read jpg images without PIL use:

import cv2 as cv
im = cv.imread(image.jpg)