downloading Olivetti faces from urllib.error.HTTPError: HTTP Error 403: Forbidden

最近在学Tensorflow和Sklearn,一个原因是想搞机器视觉,另外一个原因是想探索深入了解一下AI等等方面的知识,例如神经网络等等。

遇到的第一个问题是有些包用不了,一个可能是因为墙墙,另外一个可能是因为历史版本太久没更新导致网页地址挂了。代码是1.ipynb,具体报错如下:
#1.ipynb
from sklearn.datasets import fetch_olivetti_faces

# 从当前目录下加载人脸数据集,若没有则联网下载到当前目录下
faces = fetch_olivetti_faces(data_home='./')
downloading Olivetti faces from urllib.error.HTTPError: HTTP Error 403: Forbidden_第1张图片
downloading Olivetti faces from https://ndownloader.figshare.com/files/5976027 to ./
Traceback (most recent call last):
  File "0110.py", line 12, in 
    faces = fetch_olivetti_faces(data_home='./')
  File "/home/rwlinux/.local/lib/python3.8/site-packages/sklearn/datasets/_olivetti_faces.py", line 117, in fetch_olivetti_faces
    mat_path = _fetch_remote(FACES, dirname=data_home)
  File "/home/rwlinux/.local/lib/python3.8/site-packages/sklearn/datasets/_base.py", line 1323, in _fetch_remote
    urlretrieve(remote.url, file_path)
  File "/usr/lib/python3.8/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

解决办法也简单

只需将原数据集olivetti_py3.pkz放到当前目录下:

原链接挂了,这里放一个网盘

链接: https://pan.baidu.com/s/1ofeOk6hE4tMA-AYPJzW7cg?pwd=1111
提取码:1111

结果如下:

downloading Olivetti faces from urllib.error.HTTPError: HTTP Error 403: Forbidden_第2张图片

有用就

downloading Olivetti faces from urllib.error.HTTPError: HTTP Error 403: Forbidden_第3张图片

你可能感兴趣的:(sklearn,python)