The Python Oracle

scipy.misc module has no attribute imread?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping

--

Chapters
00:00 Scipy.Misc Module Has No Attribute Imread?
00:24 Accepted Answer Score 146
00:52 Answer 2 Score 175
01:10 Answer 3 Score 44
01:22 Answer 4 Score 62
01:35 Thank you

--

Full question
https://stackoverflow.com/questions/1534...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #installation #scipy #dependencies #pythonimaginglibrary

#avk47



ANSWER 1

Score 175


imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0. Use imageio.imread instead.

import imageio
im = imageio.imread('astronaut.png')
im.shape  # im is a numpy array
(512, 512, 3)
imageio.imwrite('imageio:astronaut-gray.jpg', im[:, :, 0])



ACCEPTED ANSWER

Score 146


You need to install Pillow (formerly PIL). From the docs on scipy.misc:

Note that Pillow is not a dependency of SciPy but the image manipulation functions indicated in the list below are not available without it:

...

imread

...

After installing Pillow, I was able to access imread as follows:

In [1]: import scipy.misc

In [2]: scipy.misc.imread
Out[2]: <function scipy.misc.pilutil.imread>



ANSWER 3

Score 62


imread is depreciated after version 1.2.0! So to solve this issue I had to install version 1.1.0.

pip install scipy==1.1.0



ANSWER 4

Score 44


For Python 3, it is best to use imread in matplotlib.pyplot:

from matplotlib.pyplot import imread