Search code examples
pythontextnlpnltktext-mining

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


I wanted to use nltk library in python. but when I run the code I have this 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

  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'
**********************************************************************

But I did it before by nltk.download() command:

import nltk
nltk.download()
nltk.download('stopwords')

from nltk.corpus import stopwords

set(stopwords.words("english"))

Solution

  • I solved this problem by download the corresponding zip file on nltk.org then manually setup the C:\nltk_data\corpora dir.