imresize導入錯誤ImportError: cannot import name 'imresize'

python代碼中導入imresize:

from scipy.misc import imresize

出現如下錯誤,無法導入:

ImportError: cannot import name 'imresize'

這是由於scipy版本問題導致的,在scipy 1.3.0之後的版本中將不再包含函數imresize:

imresize is deprecated! imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0. Use Pillow instead: numpy.array(Image.fromarray(arr).resize()).

因此,爲了使用imresize,需要將scipy降到早期的版本:

pip3 install scipy==1.1.0

問題解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章