Spacy 模块名称是关键字

Spacy Module name is keyword

我需要从 spacy.lang.is 导入 spacy 语言 class。但是,is 是 python 中的关键字,因此我在 PyCharm IDE 中遇到冲突。有没有办法解决这些问题?

spacy docs推荐导入如下:

from spacy.lang.is import Icelandic
nlp = Icelandic()

这应该避免重新分配保留关键字 is

如果这仍然让 PyCharm 抱怨,你可以使用 __import__:

Icelandic = __import__('spacy.lang.is', globals(), locals(), ['Icelandic'], 0).Icelandic