Fix Python module ‘scipy.misc’ has no attribute ‘imread’ – Python Tutorial

By | June 16, 2020

When you are processing images using python, you may encounter this error: module ‘scipy.misc’ has no attribute ‘imread’. In this tutorial, we will introduce you how to fix this problem.

Look at example code below:

import scipy.misc

original_img = np.array(scipy.misc.imread('lake-1.jpg'), dtype=np.float64) / 255

Run this code, you will get this error.

fix module scipy.misc has no attribute imread

How to fix this attribute error?

scipy.misc.imread() is removed in 1.2.0 version, we can use imageio.imread() or pillow to read image.

We can install imageio library.

pip install imageio

Then we can modify code above to:

import imageio

original_img = np.array(imageio.imread('lake-1.jpg'), dtype=np.float64) / 255

Then this attribute error is fixed.

Leave a Reply

Your email address will not be published. Required fields are marked *