python环境处理版本冲突
目录
背景和价值
查看langchain各个包的版本
pip list | grep "langchain"
在原有的虚拟环境上操作
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.
langchain-community 0.0.38 requires langchain-core<0.2.0,>=0.1.52, but you have langchain-core 0.1.33 which is incompatible.
langchain 0.1.16 requires langchain-core<0.2.0,>=0.1.42, but you have langchain-core 0.1.33 which is incompatible.
langchain-openai 0.3.11 requires langchain-core<1.0.0,>=0.3.49, but you have langchain-core 0.1.33 which is incompatible.
sqlite 版本安装和检验
查看系统默认调用的 sqlite3 路径
which sqlite3
典型输出:
/usr/bin/sqlite3 (系统自带的旧版本)
或
/usr/local/opt/sqlite/bin/sqlite3 (通过 Homebrew 安装的新版本)
brew install sqlite
python3 -c "import sqlite3; print(f'当前版本: {sqlite3.sqlite_version}')"
langchain-core 调整版本
卸载版本 pip uninstall langchain-core -y
安装某个版本 pip install langchain-core==0.1.52
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.
langchain-openai 0.3.11 requires langchain-core<1.0.0,>=0.3.49, but you have langchain-core 0.1.52 which is incompatible.
pip uninstall langchain-openai -y
pip install langchain-openai==0.1.5
终极方案,一次性更新对所有版本
pip install --upgrade
langchain-core0.1.52
langchain-openai0.1.5
langchain0.2.0
langchain-community0.2.0
在新的虚拟环境上操作
为了绝对干净,最好重新建一个虚拟环境
1 退出原有的虚拟环境 deactivate
2 创建纯净虚拟环境
python -m venv lang-chain-venv1
source lang-chain-venv1/bin/activate # Linux/macOS
3 安装langchain以及对应的包
pip install langchain==0.3.3
pip install langchain-openai
pip install langgraph

浙公网安备 33010602011771号