使用python从sklearn中获取20news的数据为什么会出错呀?请各位帮我看一下,谢谢!(注:已安装sklearn)
代码如下:
from sklearn.datasets import fetch_20newsgroups
news = fetch_20newsgroups(data_home="D:\dev\python\python3.11.3\project\python-learn\machine_learning\data_13",subset="all")
运行的结果是在我的data_13文件夹下创建了一个名为20news_home的文件夹,但是里面什么东西都没有,上面程序的错误提示如下:
Traceback (most recent call last):
File "D:\dev\python\python3.11.3\project\python-learn\machine_learning\13.py", line 6, in <module>
news = fetch_20newsgroups(subset="all")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\site-packages\sklearn\utils\_param_validation.py", line 211, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\site-packages\sklearn\datasets\_twenty_newsgroups.py", line 284, in fetch_20newsgroups
cache = _download_20newsgroups(
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\site-packages\sklearn\datasets\_twenty_newsgroups.py", line 76, in _download_20newsgroups
archive_path = _fetch_remote(ARCHIVE, dirname=target_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\site-packages\sklearn\datasets\_base.py", line 1388, in _fetch_remote
urlretrieve(remote.url, file_path)
File "D:\dev\python\python3.11.3\Lib\urllib\request.py", line 241, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\urllib\request.py", line 525, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "D:\dev\python\python3.11.3\Lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
请问各位这是什么问题导致的呀?我刚学机器学习没几天,不太懂这些提示什么意思