我想在python中使用nltk库。但是,当我运行代码时,会出现以下错误:
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
Searched in:
- 'C:\\Users\\Hossein M/nltk_data'
- 'C:\\Users\\Hossein M\\AppData\\Local\\Programs\\Python\\Python39\\nltk_data'
- 'C:\\Users\\Hossein M\\AppData\\Local\\Programs\\Python\\Python39\\share\\nltk_data'
- 'C:\\Users\\Hossein M\\AppData\\Local\\Programs\\Python\\Python39\\lib\\nltk_data'
- 'C:\\Users\\Hossein M\\AppData\\Roaming\\nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
**********************************************************************但我以前是通过nltk.download()命令这样做的:
import nltk
nltk.download()
nltk.download('stopwords')
from nltk.corpus import stopwords
set(stopwords.words("english"))发布于 2021-08-07 13:55:23
我在nltk.org上下载了相应的zip文件,然后手动设置C:\nltk_data\corpora dir,从而解决了这个问题。
https://stackoverflow.com/questions/66398873
复制相似问题