【发布时间】: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 nltk 和nltk.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