I try to import the nltk
package in Python 3.7.9 with the following code:
from nltk.corpus import stopwords
english_stop_words = set(stopwords.words('english'))
But when I run the above code, it shows me the following error:
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
I have followed what the error message and this answer say, adding import nltk
and nltk.download('stopwords')
. However, I still get the error message.
When I try python -m nltk.downloader stopwords
from this answer, it shows error zsh: command not found: python
. I know I should change python
to python3
. So I need to run the command python3 -m nltk.downloader stopwords
. When I run the command it shows the following error:
/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)>
Is there a solution to the above error or the first error Resource stopwords not found.
error? Appreciate if someone can advise. Thank you in advance!