【问题标题】:Resource stopwords not found in Python在 Python 中找不到资源停用词
【发布时间】:2022-10-25 05:51:37
【问题描述】:

我尝试使用以下代码在 Python 3.7.9 中导入 nltk 包:

from nltk.corpus import stopwords

english_stop_words = set(stopwords.words('english'))

但是当我运行上面的代码时,它显示了以下错误:

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

我按照错误消息和this answer 所说的内容添加了import nltknltk.download('stopwords')。但是,我仍然收到错误消息。

当我从this answer 尝试python -m nltk.downloader stopwords 时,它显示错误zsh: command not found: python。我知道我应该将python 更改为python3。所以我需要运行命令python3 -m nltk.downloader stopwords。当我运行命令时,它显示以下错误:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py:125: RuntimeWarning: 'nltk.downloader' found in sys.modules after import of package 'nltk', but prior to execution of 'nltk.downloader'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))
[nltk_data] Error loading stopwords: <urlopen error [SSL:
[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data]     unable to get local issuer certificate (_ssl.c:1091)>

上面的错误或者第一个错误Resource stopwords not found.错误有解决办法吗?感谢有人可以提供建议。先感谢您!

【问题讨论】:

  • 这回答了你的问题了吗? ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)(只需调整python 3.7的答案)
  • @SuperStormer 这个问题没有回答我的问题
  • 你已经运行了提供的命令?然后又试了python3 -m nltk.downloader stopwords
  • @SuperStormer 是的。当我运行提供的命令时,我仍然得到同样的错误。当我尝试python3 -m nltk.downloader stopwords 时出现另一个错误

标签: python python-3.x error-handling nltk python-3.7


【解决方案1】:

我修复了它: python -m nltk.downloader stopwords 如果你在 windows10.

【讨论】:

    猜你喜欢
    • 2021-07-22
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    • 2016-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多