Spacy 3.7.5与Python 3.12.4不兼容

xvw2m8pv  于 2个月前  发布在  Python
关注(0)|答案(3)|浏览(30)

如何复现行为

  • 安装spaCy 3.7.5
  • 使用Python 3.12.4
  • 从主页运行示例
# pip install -U spacy
# python -m spacy download en_core_web_sm
import spacy

# Load English tokenizer, tagger, parser and NER
nlp = spacy.load("en_core_web_sm")

# Process whole documents
text = (
    "When Sebastian Thrun started working on self-driving cars at "
    "Google in 2007, few people outside of the company took him "
    "seriously. “I can tell you very senior CEOs of major American "
    "car companies would shake my hand and turn away because I wasn’t "
    "worth talking to,” said Thrun, in an interview with Recode earlier "
    "this week."
)
doc = nlp(text)

# Analyze syntax
print("Noun phrases:", [chunk.text for chunk in doc.noun_chunks])
print("Verbs:", [token.lemma_ for token in doc if token.pos_ == "VERB"])

# Find named entities, phrases and concepts
for entity in doc.ents:
    print(entity.text, entity.label_)

获取错误:

ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
  File "/path/to/file.py", line 3, in <module>
    import spacy
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

这个问题似乎是pydantic的问题,已经解决了:pydantic/pydantic#9609

您的环境

  • 操作系统:Ubuntu
  • Python版本:3.12.4
  • spaCy版本:3.7.5
jm2pwxwz

jm2pwxwz1#

同样的问题,我认为解决方案是将Python版本更改为较低的3.12.3版本。

mgdq6dx1

mgdq6dx12#

在这里也存在同样的问题。

kyvafyod

kyvafyod3#

遇到同样的问题,降级可以解决问题,但如果有人在解决这个问题就更好了,因为我们不能永远依赖3.12.3版本。

相关问题