pydantic.errors.PydanticUserError: If you use `@root_validator`

报错

使用langchain时,import langchain时报错内容如下:

python 复制代码
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.7/u/root-validator-pre-skip

解决

pydantic的版本问题,将pydantic库的版本降低到1.10.13,pydantic_core等相关依赖库的版本也会自动降低。

python 复制代码
pip install pydantic==1.10.13 -i  https://pypi.tuna.tsinghua.edu.cn/simple
相关推荐
知其然亦知其所以然14 小时前
三分钟接入!SpringAI 玩转 Perplexity 聊天模型实战
后端·spring·langchain
用户91251886776714 小时前
LangChain集成Qwen大模型多种方式分享与最佳实践
langchain
玲小珑15 小时前
LangChain.js 完全开发手册(六)Vector 向量化技术与语义搜索
前端·langchain·ai编程
无难事者若执1 天前
20250906-01:开始创建LangChain的第一个项目
langchain
年年测试2 天前
在LangChain中无缝接入MCP服务器扩展AI智能体能力
服务器·人工智能·langchain
信马堂2 天前
MCP Token超限问题解决方案
人工智能·langchain
freephp2 天前
企业级LLM已经到了next level:LangChain + DeepSeek = 王炸
langchain·deepseek
小陈phd2 天前
高级RAG策略学习(四)——上下文窗口增强检索RAG
人工智能·学习·langchain
YUELEI1182 天前
langchain 提示模版 PromptTemplate
python·langchain
东方不败之鸭梨的测试笔记2 天前
LangChain: Models, Prompts 模型和提示词
人工智能·python·langchain