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)
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值