刚刚装了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