LookupError: Resource stopwords not found. Please use the NLTK Downloader to obtain the resource

LookupError: Resource stopwords not found. Please use the NLTK Downloader to obtain the resource

我想在 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"))

我通过在 nltk.org 下载相应的 zip 文件然后手动设置 C:\nltk_data\corpora 目录解决了这个问题。