Search code examples
python-3.xnlpnltkcorpus

nltk.corpus - 'getset_descriptor' object has no attribute 'setdefault'


I am using below code and importing stop words from nltk

   #from nltk.corpus import words as word_corp
    from nltk.corpus import stopwords
    nlp = spacy.load('en_core_web_sm')
    phrase_matcher = PhraseMatcher(nlp.vocab)
    en_words = nltk.corpus.words.words('en')
    stop_words = stopwords.words('english')

But error is AttributeError: 'getset_descriptor' object has no attribute 'setdefault' for ----> 3 nlp = spacy.load('en_core_web_sm') this line.


Solution

  • I had this issue as well - what versions of Python/spaCy are you using?

    It happened to me with Python 3.9.1 + spaCy 2.2.4.

    It worked for me after upgrading spaCy to 3.0.0 OR downgrading Python to 3.6.8 (didn't try other versions)