赞
踩
下载nltk中的stopwords报错如何解决
错误如下:
[nltk_data] Error loading stopwords: <urlopen error [Errno 11004]
[nltk_data] getaddrinfo failed>
Traceback (most recent call last):
File "D:\Anaconda\envs\PyTorch\lib\site-packages\nltk\corpus\util.py", line 84, in __load
root = nltk.data.find(f"{self.subdir}/{zip_name}")
File "D:\Anaconda\envs\PyTorch\lib\site-packages\nltk\data.py", line 583, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('stopwords')
For more information see: https://www.nltk.org/data.html
Attempted to load corpora/stopwords.zip/stopwords/
Searched in:
- 'C:\\Users\\19819/nltk_data'
- 'D:\\Anaconda\\envs\\PyTorch\\nltk_data'
- 'D:\\Anaconda\\envs\\PyTorch\\share\\nltk_data'
- 'D:\\Anaconda\\envs\\PyTorch\\lib\\nltk_data'
- 'C:\\Users\\19819\\AppData\\Roaming\\nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
**********************************************************************
解决方案一:
在控制台中运行代码:
import nltk
... nltk.download()
... nltk.download('stopwords')
这时会弹出报错页面,只需将sever index换成下图中网址
并选择Corpora中的stopwords开始下载即可
解决方案二:
手动下载网址(http://www.nltk.org/nltk_data/)下载对应的语料,即stopwords;然后放到上述第一个路径中即可。但是下载链接有可能打不开
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。