AttributeError: ‘module’ object has no attribute ‘misc’

How to Fix AttributeError - 'module' object has no attribute 'misc'

AttributeError: ‘module’ object has no attribute ‘misc’ error occurs because the “misc submodule was deprecated and has been removed in later versions of scipy.”

Reproduce the error

import scipy.misc

#Load the Lena image into an array, (yes scipy does have a lena function)
lena = scipy.misc.lena()

Output

AttributeError: scipy.misc is deprecated and has no attribute lena.

Let’s upgrade the scipy package and see if the latest version can fix this issue.

To upgrade the scipy package, use this command: pip install –upgrade scipy

upgrade the scipy package

Now, try again the above code and see if it succeeds.

And we get the same output.

AttributeError: scipy.misc is deprecated and has no attribute lena.

That means the scipy.misc has been deprecated, and you cannot use this attribute anymore.

How to fix the error?

To fix the AttributeError: ‘module’ object has no attribute ‘misc’, it is recommended to “use image processing libraries like imageio or PIL (from Pillow) instead.”

That’s it!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.