当前位置:   article > 正文

安装使用LangChain时的报错解决_pydantic.errors.pydanticusererror: a non-annotated

pydantic.errors.pydanticusererror: a non-annotated attribute was detected: `

刚刚装了LangChain但是引入各种包都报错,原因貌似为 Python3.7 不支持 LangChain,需要开启一个新的Python3.10环境,再重新安装即可正常运行。

创建新的python环境

conda create -n new_env python==3.10

重新安装

pip install langchain

这是当时的报错信息,写出来希望小伙伴来避避坑

 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\__init__.py", line 8, in <module>
   from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\agents\__init__.py", line 2, in <module>
   from langchain.agents.agent import Agent
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\agents\agent.py", line 10, in <module>
   from langchain.chains.base import Chain
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\chains\__init__.py", line 2, in <module>
   from langchain.chains.conversation.base import ConversationChain
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\chains\conversation\base.py", line 7, in <module>
   from langchain.chains.conversation.memory import ConversationBufferMemory
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\chains\conversation\memory.py", line 7, in <module>
   from langchain.chains.conversation.prompt import SUMMARY_PROMPT
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\chains\conversation\prompt.py", line 2, in <module>
   from langchain.prompts.prompt import PromptTemplate
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\prompts\__init__.py", line 2, in <module>
   from langchain.prompts.base import BasePromptTemplate
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\prompts\base.py", line 35, in <module>
   class BasePromptTemplate(BaseModel, ABC):
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\langchain\prompts\base.py", line 41, in BasePromptTemplate
   @root_validator()
 File "E:\ProgramData\miniconda3\envs\common\lib\site-packages\pydantic\deprecated\class_validators.py", line 231, in root_validator
   code='root-validator-pre-skip',
pydantic.errors.PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.

For further information visit https://errors.pydantic.dev/2.0.3/u/root-validator-pre-skip

Process finished with exit code 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/614821
推荐阅读
相关标签
  

闽ICP备14008679号