当前位置: 首页 > 工具软件 > 2people > 使用案例 >

成功解决fetch_lfw_people导入读取时报错的问题

谷梁嘉运
2023-12-01

问题

jupyter notebook读取数据时出现了这样的问题:The Python Imaging Library (PIL) is required to load data from jpeg files

(如果是出现了 Compressed file ended before the end-of-stream marker was reached 这个问题说明下载失败了,解决办法见https://blog.csdn.net/pyufftj/article/details/79756327)

错误信息:
~\Envs\py37\lib\site-packages\sklearn\externals_pilutil.py in imread(name, flatten, mode)
194 “”"
195 if not pillow_installed:
–> 196 raise ImportError(“The Python Imaging Library (PIL) is required to load data from jpeg files”)

解决办法

在当前运行环境下安装Image库
然后再重启jupyter notebook就可以了

具体情况

1.从报错信息上找到出错位置在_pilutil.py文件,打开查看具体的代码,发现要导入PIL库,而PIL不支持3版本的python

2.导入PIL库失败后_pilutil模块会尝试导入Image库,仍然失败后才会报错The Python Imaging Library (PIL) is required to load data from jpeg files

3.所以如果你的pyhton是2版本可以直接安装PIL库,否则安装Image库也可以解决问题

4.实在不行的话我准备好了可直接读取的数据文件:链接:https://pan.baidu.com/s/1wGIEH1AS_Hqd70fzpkwMFw
提取码:kn83
放在:
/Users/your_name/scikit_learn_data/
这个文件夹下就可以了

 类似资料: