module 'scipy.ndimage' has no attribute 'imread'

问题

#导入ndimage
from scipy import ndimage
#调用imread
fname = "images/" + my_image
image = np.array(ndimage.imread(fname))

报错:

module ‘scipy.ndimage’ has no attribute ‘imread’

环境

  1. Python版本:3.7.4
  2. scipy版本:1.2.1
  3. PIL版本:6.0.0

解决方案

方案一:

  1. 打开Cmd,安装imageio
pip3 install imageio
  1. 调用imageio.imread
import imageio
fname = "images/" + my_image
image = np.array(imageio.imread(fname))

方案二:

from matplotlib.pyplot import imread

参考

[1]scipy.misc module has no attribute imread?

你可能感兴趣的:(问题解决)