ImportError: cannot import name 'imread'

cill 提问于 3周前
from scipy.misc import imread, imresize

在执行上面语句时出现的错误:

E:\py\face_classification\venv\lib\site-packages\h5py\__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "E:/py/face_classification/src/video_emotion_color_demo.py", line 13, in <module>
    from utils.preprocessor import preprocess_input
  File "E:\py\face_classification\src\utils\preprocessor.py", line 2, in <module>
    from scipy.misc import imread, imresize
ImportError: cannot import name 'imread'

求解!

回答 2
2 个回答

没有安装 pil 或 pillow 包,pil 停更了,推荐用 pillow。

 pip install pillow

因为该方法依赖 pil 库,所以导入失败,api 中描述:

@numpy.deprecate(message="`imread` is deprecated in SciPy 1.0.0, "
                         "and will be removed in 1.2.0.\n"
                         "Use ``imageio.imread`` instead.")
def imread(name, flatten=False, mode=None):
    """
    Read an image from a file as an array.

    This function is only available if Python Imaging Library (PIL) is installed.

    ...
    """

并且它本身也不被推家使用了。希望能帮到你。

回复
3周前

pip install pil

回复
需要登录后才能回答,快点击 来分享你的回答吧~
2 关注
0 收藏,17 浏览
邀请回答
相关问题
分享到