ImportError: cannot import name imresize from scipy.misc
程序员文章站
2022-03-21 11:05:43
...
在Pytorch中使用imresize函数报出如下错误
ImportError: cannot import name 'imresize' from 'scipy.misc'
imresize函数已被最新的SciPy给弃用。
有两个解决方案
1、安装Pillow试试
pip install Pillow
如果安装以后还是报错,则需要使用其他的函数替换imresize
2、使用numpy+Pillow库试试
from PIL import Image
import numpy as np
norm_map = imresize(raw_hm, (height, width))
#换成
norm_map = np.array(Image.fromarray(raw_hm).resize( (height, width)))
应该就可以了
推荐阅读
-
pycharm读取图片,提示ImportError: cannot import name imread解决方法
-
ImportError: cannot import name 'cross_validation' from 'sklearn'
-
cannot import name 'Flask' from 'flask'
-
ImportError: cannot import name 'Optional'
-
Python中使用Enum类时出现cannot import name ‘Enum‘ from partially initialized module ‘enum‘
-
cannot import name ‘Graph‘ from ‘pyecharts‘
-
解决pyecharts importerror问题:cannot import name ‘bar’ from pyecharts
-
ImportError: cannot import name ‘Bar‘ from ‘pyecharts‘ (D:\Anaconda3-2019.03\Anaconda3\lib\site-pack
-
2021-06-13cannot import name ‘Bar‘ from ‘pyecharts.charts‘ (C:\Users\SieburgShen\AppData\Roaming\Pyt
-
ImportError: cannot import name 'connections' from 'haystack'