Tag Archives: imsave

How to Solve Error “ImportError: cannot import name imsave“

Problem description

Today, when running a GitHub code two years ago, an error was reported:

from scipy.misc import imsave

ImportError: cannot import name 'imsave'

But after checking, I found that I have installed the SciPy module. When checking the internal function module of SciPy, I found that there are no functions such as imsave

import scipy.misc

print(dir(scipy.misc))

After searching, it is found that the reason is the SciPy version: after SciPy 1.3, functions such as SciPy. Misc. Imread/imsave will be discarded.

resolvent

To re install the previous version of SciPy, first log in to the official website of SciPy and find the corresponding WHL file. As the python environment of this machine is Ubuntu + python = 3.6.9, download the third corresponding file:

Then uninstall the previous SciPy and install the file

# uninstal scipy
pip uninstall scipy


# install
pip install scipy-1.2.0-cp36-cp36m-manylinux1_x86_64.whl

Check the SciPy internal function again

 

You can see that there are functions like imread, imsave, imshow, etc