当前位置:   article > 正文

import spacy报错

import spacy报错

报错内容

Traceback (most recent call last):
File “D:\dataset\sap-sam-main\src\sapsam\detector.py”, line 1, in
import spacy
File “D:\Anaconda\envs\sapsam\lib\site-packages\spacy_init_.py”, line 14, in
from . import pipeline # noqa: F401
File “D:\Anaconda\envs\sapsam\lib\site-packages\spacy\pipeline_init_.py”, line 1, in
from .attributeruler import AttributeRuler
File “D:\Anaconda\envs\sapsam\lib\site-packages\spacy\pipeline\attributeruler.py”, line 6, in
from .pipe import Pipe
File “spacy\pipeline\pipe.pyx”, line 1, in init spacy.pipeline.pipe
File “spacy\vocab.pyx”, line 1, in init spacy.vocab
File “D:\Anaconda\envs\sapsam\lib\site-packages\spacy\tokens_init_.py”, line 1, in
from .doc import Doc
File “spacy\tokens\doc.pyx”, line 36, in init spacy.tokens.doc
File “D:\Anaconda\envs\sapsam\lib\site-packages\spacy\schemas.py”, line 222, in
class TokenPattern(BaseModel):
File “pydantic\main.py”, line 205, in pydantic.main.ModelMetaclass.__new__
File “pydantic\fields.py”, line 491, in pydantic.fields.ModelField.infer
File “pydantic\fields.py”, line 421, in pydantic.fields.ModelField.__init__
File “pydantic\fields.py”, line 537, in pydantic.fields.ModelField.prepare
File “pydantic\fields.py”, line 634, in pydantic.fields.ModelField._type_analysis
File “pydantic\fields.py”, line 641, in pydantic.fields.ModelField._type_analysis
File “D:\Anaconda\envs\sapsam\lib\typing.py”, line 774, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class

报错原因

pydantic 的版本和 spacy 的版本不匹配出现该问题

解决方案

1.卸载 pydantic

pip uninstall pydantic
  • 1

2.重新安装 pydantic 会出现错误提示信息

pip install pydantic
  • 1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
confection 0.1.0 requires pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4, but you have pydantic 2.1.1 which is incompatible.
spacy 3.4.1 requires pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4, but you have pydantic 2.1.1 which is incompatible.
thinc 8.1.10 requires pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4, but you have pydantic 2.1.1 which is incompatible.
  • 1
  • 2
  • 3
  • 4

spacy 3.4.1 需要 pydantic 版本 !=1.8,!=1.8.1,<1.10.0,>=1.7.4

3.卸载 pydantic 重新安装1.7.4版本的 pydantic

pip install pydantic==1.7.4
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/363662
推荐阅读
相关标签
  

闽ICP备14008679号