云南网站做的好的公司哪家好,修改wordpress页脚信息,湖南网页,黑蜘蛛网站解决#xff1a;AttributeError: module ‘scipy.misc’ has no attribute ‘imsave’ 文章目录 解决#xff1a;AttributeError: module scipy.misc has no attribute imsave背景报错问题报错翻译报错位置代码报错原因解决方法方法一 scipy版本回退#xff08;不推荐#…
解决AttributeError: module ‘scipy.misc’ has no attribute ‘imsave’ 文章目录 解决AttributeError: module scipy.misc has no attribute imsave背景报错问题报错翻译报错位置代码报错原因解决方法方法一 scipy版本回退不推荐方法二 使用imageio保存图片即可推荐方法三 使用opencv保存图片推荐方法四 使用matplotlib保存图片推荐今天的分享就到此结束了 背景 在使用之前的代码时报错 Traceback (most recent call last): File “xxx”, line xx, in misc.imsave(output_path, scaled_temp) AttributeError: module ‘scipy.misc’ has no attribute ‘imsave’ 报错问题 Traceback (most recent call last):File xxx, line xx, in modulemisc.imsave(output_path, scaled_temp)
AttributeError: module scipy.misc has no attribute imsave报错翻译
主要报错信息内容翻译如下所示 Traceback (most recent call last):File xxx, line xx, in modulemisc.imsave(output_path, scaled_temp)
AttributeError: module scipy.misc has no attribute imsave翻译
追溯最近一次通话 文件“xxx”第xx行在中 misc.imsaveoutput_pathscaled_temp AttributeError模块“scipy.misc”没有属性“imsave” 报错位置代码
from scipy import misc
misc.imsave(output_path, scaled_temp)报错原因
经过查阅资料发现这个错误产生的原因是scipy模块1.20版本之后该方法已经被弃用了如果继续使用这个方法就会报这样的错误。
小伙伴们按下面的解决方法即可解决 解决方法
要解决这个错误需要这里总结了以下几个解决办法
方法一 scipy版本回退不推荐
回退到scipy模块1.20之前的版本版本回退的pip指令如下
pip install scipy1.2.1 -i https://pypi.tuna.tsinghua.edu.cn/simple注意因为版本回退后会造成该模块与环境中的tensorflow包或者其他包的不兼容后续还得再更新回来或者是单独建一个环境比较麻烦。
方法二 使用imageio保存图片即可推荐
imageio的方法正确的代码是
import imageio
imageio.imwrite(output_path,scaled_temp)方法三 使用opencv保存图片推荐
opencv的方法
import cv2
# 读取
img cv.imread(imagepath)
# 显示
cv2.imshow(window_title,img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# 保存
cv.imwrite(savepath, img)方法四 使用matplotlib保存图片推荐
matplotlib的方法
from PIL import Image
import matplotlib.pyplot as pltplt.imshow(img)
plt.savefig(img_name.png)# 图像保存
plt.show()今天的分享就到此结束了 欢迎点赞评论关注三连