No module named 'scipy.misc.imsave' 解决办法

在使用scipy.misc.imsave函数时出现了No module named ‘scipy.misc.imsave’ 的错误,现在的博客上大多解决办法都集中于:

  • 安装pillow
  • 降低scipy版本
  • 配置imsave, imread的环境变量
    等方法,实际上翻看一下scipy的官方文档,可以看到:
Functions from scipy.interpolate (spleval, spline, splmake, and spltopp) and functions from scipy.misc (bytescale, 
fromimage, imfilter, imread, imresize, imrotate, imsave, imshow, toimage) have been removed. The former set has 
been deprecated since v0.19.0 and the latter has been deprecated since v1.0.0. Similarly, aliases from 
scipy.misc (comb, factorial, factorial2, factorialk, logsumexp, pade, info, source, who) which have been 
deprecated since v1.0.0 are removed. SciPy documentation for v1.1.0 can be used to track the new import locations 
for the relocated functions.

scipy.misc (bytescale, fromimage, imfilter, imread, imresize, imrotate, imsave, imshow, toimage)这些函数已经被弃用了。

解决方法:
用其他函数来代替,比如imageio

  1. 下载imageio pip install imageio
  2. 查看imageio的可用函数, import imageio, 再输入dir(imageio)命令,即可看到imageio的如下函数
['RETURN_BYTES', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__',
 '__path__', '__spec__', '__version__', 'core', 'formats', 'get_reader', 'get_writer', 'help', 'imread', 'imsave', 
 'imwrite', 'mimread', 'mimsave', 'mimwrite', 'mvolread', 'mvolsave', 'mvolwrite', 'plugins', 'read', 'save',
  'show_formats', 'volread', 'volsave', 'volwrite']
  1. 使用
import imageio
imageio.imsave(fname, pil_img)

你可能感兴趣的:(python日常,imsave,imread,misc)