Image.PIL库没有属性(函数)fromarray的解决方法

问题来源

将一个ndarray格式的图片转换为PIL.Image的时候一直提示type object ‘Image’ has no attribute ‘fromarray’。通过检查PIL.Image发现,该类并不含有官方文档所说的fromarray函数
官方文档

解决方案

重新安装Pillow,就能在函数库搜索到fromarray函数

pip uninstall Pillow
pip install Pillow==7.1.2

在这里插入图片描述

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