0

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!

My Car
  • 4,198
  • 5
  • 17
  • 50
  • Does this answer your question? [ssl.SSLError: \[SSL: CERTIFICATE\_VERIFY\_FAILED\] certificate verify failed (\_ssl.c:749)](https://stackoverflow.com/q/41691327) (just adapt the answer for python 3.7) – SuperStormer Oct 10 '22 at 02:29
  • @SuperStormer this question doesn't answer my question – My Car Oct 10 '22 at 02:38
  • You've ran the command provided? Then tried `python3 -m nltk.downloader stopwords` again? – SuperStormer Oct 10 '22 at 02:39
  • @SuperStormer yes. I still get the same error when I run the provided command. When I try `python3 -m nltk.downloader stopwords` I get another error – My Car Oct 10 '22 at 02:41

1 Answers1

0

I fixed it with: python -m nltk.downloader stopwords. If you are on windows10.

tonyoni
  • 1
  • 1
  • Please format the command as code, possibly on its own line. Right now, it's a bit ambiguous which parts of the text are and aren't part of the command. – rainbow.gekota Oct 28 '22 at 08:09