nltk.corpus - 'getset_descriptor' 对象没有属性 'setdefault'

问题描述

我正在使用以下代码并从 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')

错误AttributeError: 'getset_descriptor' object has no attribute 'setdefault' for ----> 3 nlp = spacy.load('en_core_web_sm') 这一行。

解决方法

我也遇到了这个问题 - 您使用的是什么版本的 Python/spaCy?

Python 3.9.1 + spaCy 2.2.4 发生在我身上。

在将 spaCy 升级到 3.0.0 OR 将 Python 降级到 3.6.8(没有尝试其他版本)后对我有用