使用pip安装的时候遇到了以下的依赖冲突问题,解决流程记录一下,相似的过程可以进行排查:
(hello-agent) tipriest@uranus:~/documents/hello-agents/code/chapter15/helloagents-ai-town/backend (main*) $ pip install -r requirements.txt
collecting fastapi>=0.104.0 (from -r requirements.txt (line 2))
downloading fastapi-0.124.4-py3-none-any.whl.metadata (30 kb)
collecting uvicorn>=0.24.0 (from uvicorn[standard]>=0.24.0->-r requirements.txt (line 3))
downloading uvicorn-0.38.0-py3-none-any.whl.metadata (6.8 kb)
requirement already satisfied: pydantic>=2.0.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from -r requirements.txt (line 4)) (2.12.5)
requirement already satisfied: requests>=2.31.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from -r requirements.txt (line 5)) (2.32.5)
collecting python-multipart>=0.0.6 (from -r requirements.txt (line 8))
downloading python_multipart-0.0.20-py3-none-any.whl.metadata (1.8 kb)
collecting pytest>=7.4.0 (from -r requirements.txt (line 11))
downloading pytest-9.0.2-py3-none-any.whl.metadata (7.6 kb)
requirement already satisfied: httpx>=0.25.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from -r requirements.txt (line 12)) (0.28.1)
collecting hello-agents>=0.2.4 (from -r requirements.txt (line 15))
downloading hello_agents-0.2.8-py3-none-any.whl.metadata (12 kb)
collecting starlette<0.51.0,>=0.40.0 (from fastapi>=0.104.0->-r requirements.txt (line 2))
downloading starlette-0.50.0-py3-none-any.whl.metadata (6.3 kb)
requirement already satisfied: typing-extensions>=4.8.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from fastapi>=0.104.0->-r requirements.txt (line 2)) (4.15.0)
collecting annotated-doc>=0.0.2 (from fastapi>=0.104.0->-r requirements.txt (line 2))
downloading annotated_doc-0.0.4-py3-none-any.whl.metadata (6.6 kb)
requirement already satisfied: annotated-types>=0.6.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from pydantic>=2.0.0->-r requirements.txt (line 4)) (0.7.0)
requirement already satisfied: pydantic-core==2.41.5 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from pydantic>=2.0.0->-r requirements.txt (line 4)) (2.41.5)
requirement already satisfied: typing-inspection>=0.4.2 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from pydantic>=2.0.0->-r requirements.txt (line 4)) (0.4.2)
requirement already satisfied: anyio<5,>=3.6.2 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from starlette<0.51.0,>=0.40.0->fastapi>=0.104.0->-r requirements.txt (line 2)) (4.12.0)
requirement already satisfied: exceptiongroup>=1.0.2 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from anyio<5,>=3.6.2->starlette<0.51.0,>=0.40.0->fastapi>=0.104.0->-r requirements.txt (line 2)) (1.3.1)
requirement already satisfied: idna>=2.8 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from anyio<5,>=3.6.2->starlette<0.51.0,>=0.40.0->fastapi>=0.104.0->-r requirements.txt (line 2)) (3.11)
collecting click>=7.0 (from uvicorn>=0.24.0->uvicorn[standard]>=0.24.0->-r requirements.txt (line 3))
downloading click-8.3.1-py3-none-any.whl.metadata (2.6 kb)
requirement already satisfied: h11>=0.8 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from uvicorn>=0.24.0->uvicorn[standard]>=0.24.0->-r requirements.txt (line 3)) (0.16.0)
requirement already satisfied: charset_normalizer<4,>=2 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from requests>=2.31.0->-r requirements.txt (line 5)) (3.4.4)
requirement already satisfied: urllib3<3,>=1.21.1 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from requests>=2.31.0->-r requirements.txt (line 5)) (2.6.2)
requirement already satisfied: certifi>=2017.4.17 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from requests>=2.31.0->-r requirements.txt (line 5)) (2025.11.12)
collecting iniconfig>=1.0.1 (from pytest>=7.4.0->-r requirements.txt (line 11))
downloading iniconfig-2.3.0-py3-none-any.whl.metadata (2.5 kb)
requirement already satisfied: packaging>=22 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from pytest>=7.4.0->-r requirements.txt (line 11)) (25.0)
collecting pluggy<2,>=1.5 (from pytest>=7.4.0->-r requirements.txt (line 11))
using cached pluggy-1.6.0-py3-none-any.whl.metadata (4.8 kb)
requirement already satisfied: pygments>=2.7.2 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from pytest>=7.4.0->-r requirements.txt (line 11)) (2.19.2)
collecting tomli>=1 (from pytest>=7.4.0->-r requirements.txt (line 11))
using cached tomli-2.3.0-py3-none-any.whl.metadata (10 kb)
requirement already satisfied: httpcore==1.* in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from httpx>=0.25.0->-r requirements.txt (line 12)) (1.0.9)
collecting openai<2.0.0,>=1.0.0 (from hello-agents>=0.2.4->-r requirements.txt (line 15))
downloading openai-1.109.1-py3-none-any.whl.metadata (29 kb)
requirement already satisfied: python-dotenv<2.0.0,>=0.19.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from hello-agents>=0.2.4->-r requirements.txt (line 15)) (1.2.1)
collecting beautifulsoup4<5.0.0,>=4.9.0 (from hello-agents>=0.2.4->-r requirements.txt (line 15))
downloading beautifulsoup4-4.14.3-py3-none-any.whl.metadata (3.8 kb)
collecting numpy<3.0.0,>=2.0.0 (from hello-agents>=0.2.4->-r requirements.txt (line 15))
using cached numpy-2.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (62 kb)
collecting networkx<4.0.0,>=2.6.0 (from hello-agents>=0.2.4->-r requirements.txt (line 15))
using cached networkx-3.4.2-py3-none-any.whl.metadata (6.3 kb)
requirement already satisfied: tiktoken>=0.5.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from hello-agents>=0.2.4->-r requirements.txt (line 15)) (0.12.0)
collecting soupsieve>=1.6.1 (from beautifulsoup4<5.0.0,>=4.9.0->hello-agents>=0.2.4->-r requirements.txt (line 15))
downloading soupsieve-2.8-py3-none-any.whl.metadata (4.6 kb)
requirement already satisfied: distro<2,>=1.7.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0->hello-agents>=0.2.4->-r requirements.txt (line 15)) (1.9.0)
requirement already satisfied: jiter<1,>=0.4.0 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0->hello-agents>=0.2.4->-r requirements.txt (line 15)) (0.12.0)
requirement already satisfied: sniffio in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0->hello-agents>=0.2.4->-r requirements.txt (line 15)) (1.3.1)
requirement already satisfied: tqdm>4 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from openai<2.0.0,>=1.0.0->hello-agents>=0.2.4->-r requirements.txt (line 15)) (4.67.1)
requirement already satisfied: regex>=2022.1.18 in /home/tipriest/anaconda3/envs/hello-agent/lib/python3.10/site-packages (from tiktoken>=0.5.0->hello-agents>=0.2.4->-r requirements.txt (line 15)) (2025.11.3)
collecting httptools>=0.6.3 (from uvicorn[standard]>=0.24.0->-r requirements.txt (line 3))
downloading httptools-0.7.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (3.5 kb)
collecting pyyaml>=5.1 (from uvicorn[standard]>=0.24.0->-r requirements.txt (line 3))
using cached pyyaml-6.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (2.4 kb)
collecting uvloop>=0.15.1 (from uvicorn[standard]>=0.24.0->-r requirements.txt (line 3))
downloading uvloop-0.22.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (4.9 kb)
collecting watchfiles>=0.13 (from uvicorn[standard]>=0.24.0->-r requirements.txt (line 3))
downloading watchfiles-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.9 kb)
collecting websockets>=10.4 (from uvicorn[standard]>=0.24.0->-r requirements.txt (line 3))
using cached websockets-15.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.8 kb)
downloading fastapi-0.124.4-py3-none-any.whl (113 kb)
downloading starlette-0.50.0-py3-none-any.whl (74 kb)
downloading uvicorn-0.38.0-py3-none-any.whl (68 kb)
downloading python_multipart-0.0.20-py3-none-any.whl (24 kb)
downloading pytest-9.0.2-py3-none-any.whl (374 kb)
using cached pluggy-1.6.0-py3-none-any.whl (20 kb)
downloading hello_agents-0.2.8-py3-none-any.whl (251 kb)
downloading beautifulsoup4-4.14.3-py3-none-any.whl (107 kb)
using cached networkx-3.4.2-py3-none-any.whl (1.7 mb)
using cached numpy-2.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 mb)
downloading openai-1.109.1-py3-none-any.whl (948 kb)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 948.6/948.6 kb 7.1 mb/s 0:00:00
downloading annotated_doc-0.0.4-py3-none-any.whl (5.3 kb)
downloading click-8.3.1-py3-none-any.whl (108 kb)
downloading iniconfig-2.3.0-py3-none-any.whl (7.5 kb)
downloading soupsieve-2.8-py3-none-any.whl (36 kb)
using cached tomli-2.3.0-py3-none-any.whl (14 kb)
downloading httptools-0.7.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (440 kb)
using cached pyyaml-6.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (770 kb)
downloading uvloop-0.22.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (3.7 mb)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 mb 12.8 mb/s 0:00:00
downloading watchfiles-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (455 kb)
using cached websockets-15.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (181 kb)
installing collected packages: websockets, uvloop, tomli, soupsieve, pyyaml, python-multipart, pluggy, numpy, networkx, iniconfig, httptools, click, annotated-doc, uvicorn, pytest, beautifulsoup4, watchfiles, starlette, openai, fastapi, hello-agents
attempting uninstall: openai
found existing installation: openai 2.11.0
uninstalling openai-2.11.0:
successfully uninstalled openai-2.11.0
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.
generate-parameter-library-py 0.5.0 requires jinja2, which is not installed.
generate-parameter-library-py 0.5.0 requires typeguard, which is not installed.
successfully installed annotated-doc-0.0.4 beautifulsoup4-4.14.3 click-8.3.1 fastapi-0.124.4 hello-agents-0.2.8 httptools-0.7.1 iniconfig-2.3.0 networkx-3.4.2 numpy-2.2.6 openai-1.109.1 pluggy-1.6.0 pytest-9.0.2 python-multipart-0.0.20 pyyaml-6.0.3 soupsieve-2.8 starlette-0.50.0 tomli-2.3.0 uvicorn-0.38.0 uvloop-0.22.1 watchfiles-1.1.1 websockets-15.0.1先说结论:你这次 pip install -r requirements.txt 实际上已经安装成功了,只是 pip 在最后给了一个**“潜在依赖冲突警告”**,提醒你:当前环境里已经安装的一个包 generate-parameter-library-py 有未满足的依赖(jinja2、typeguard)。
这和你刚刚装的 fastapi / hello-agents 等并不直接冲突,只是说明你的环境里有一个“半残废”的包。
下面我按“排查思路”一步步讲,今后你遇到类似输出可以自己判断、处理。
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. generate-parameter-library-py 0.5.0 requires jinja2, which is not installed. generate-parameter-library-py 0.5.0 requires typeguard, which is not installed. successfully installed ...
含义拆开:
pip's dependency resolver does not currently take into account all the packages that are installed.- 这句是 pip 的“已知局限”声明:
它在解析依赖时主要考虑这次要安装/升级的包,对环境里早就存在的老包考虑不充分。
- 这句是 pip 的“已知局限”声明:
generate-parameter-library-py 0.5.0 requires jinja2, which is not installed.- 说明你当前环境中装了
generate-parameter-library-py==0.5.0,
但它声明要依赖jinja2和typeguard,而这两个当前没装。
- 说明你当前环境中装了
- 最后一行
successfully installed ...- 证明:这次 requirements.txt 里的包,其实都装成功了;
报错只是对“环境整体依赖状态”的警告。
- 证明:这次 requirements.txt 里的包,其实都装成功了;
所以这里不是“fastapi 安装失败”,也不是“hello-agents 有问题”,
而是“你的环境里有个以前装过的包(generate-parameter-library-py)依赖不齐”。
2. 通用排查步骤(可当小模板用)
以后看到类似 pip 报警,可以按这个顺序排查:
步骤 1:确认这次要装的包有没有安装成功
- 看最后有没有
successfully installed ... - 或直接进环境里跑:
python -c "import fastapi, hello_agents; print(fastapi.__version__)"
你这次的输出明确有 successfully installed ...,所以当前项目依赖已就绪。
步骤 2:确认报错里提到的是哪些“冲突包”
本例里是:
generate-parameter-library-py 0.5.0- 缺少依赖:
jinja2、typeguard
常见两种情况:
- 这是你项目里用不到的包
- 可能是你过去在这个环境里尝试过别的项目装的
- 那么可以直接删掉它,保持环境干净
- 这是你另外一个项目确实需要的包
- 那么就在这个环境里把它依赖补齐,或者更好的是:给它单独建一个环境
步骤 3:查一下这个包从哪来的、是不是当前项目真的需要
在当前 conda 环境里执行:
pip show generate-parameter-library-py
看输出:
location:安装目录required-by:哪些包依赖了它(通常为空说明你是手动装的)version等信息
如果你发现:
- 当前这个“helloagents-ai-town”项目的
requirements.txt里并没有它 - 也没有任何其他依赖它的包
那大概率是个“历史遗留垃圾包”,可以直接删。
步骤 4:决定“删掉它”还是“把依赖补齐”
4.1 如果删掉它(推荐,环境更干净)
在当前 hello-agent 环境里:
pip uninstall generate-parameter-library-py
然后再跑一次:
pip check
pip check 的作用是:检查当前环境里所有已安装包的依赖是否都满足。
如果输出为空 / all good 就说明环境相对干净了。
建议:在“专用于某个项目的环境”里,只保留这个项目真正需要的包,其他历史包尽量卸载。
4.2 如果你确实还需要这个包(比如是你另一个项目用的)
那就把它依赖补齐即可:
pip install jinja2 typeguard pip check
之后 pip 再安装别的东西时,就不会再提这个包的依赖缺失问题了。
但更好的做法是:
给这个“用 generate-parameter-library-py 的项目”单独建一个 conda 环境,避免互相污染。
3. 结合你当前环境,说一套更“干净”的做法
目前情况:
- 你在 conda 环境
hello-agent里用 pip 装了这套 ai town 的依赖 - 环境里还残留一个旧包
generate-parameter-library-py,而它依赖没装全
建议今后针对每个项目:
为项目新建一个 conda 环境(你已经这么做了,这是好习惯):
conda create -n hello-agent python=3.10 conda activate hello-agent
在这个环境里,只做两类安装:
- 该项目的
requirements.txt - 你确实“为了这个项目”需要的额外包
对于不确定来源、其他项目历史遗留的包(比如这次的 generate-parameter-library-py):
- 能卸载就卸载
- 如果要用,就给它开自己的环境,不要混在这个项目里
4. 一个“日常排查小 checklist”
以后碰到类似 pip 的长输出,可以按这个顺序:
最后一行有没有 successfully installed?
- 有:本次安装成功,报错多半是“环境整体不一致警告”
- 没有:往上翻,找“哪一个包安装失败”“是下载失败还是编译失败还是版本冲突”
报错提到了哪些 package?
- 是这次要装的,还是过去残留的?
对每个提到的包,问自己三个问题:
- 这个包是当前项目真的需要吗?
- 如果不是:
pip uninstall 包名 - 如果是:把它依赖补齐 / 单独给它一个环境
最后跑一次:
pip check
看看剩下还有没有未满足的依赖。
5. 针对你这个具体例子,可以直接这样做
在 hello-agent 环境中:
# 1. 看看这个包到底啥情况(可选) pip show generate-parameter-library-py # 2. 如果你确认现在这个项目不需要它,就干脆删掉 pip uninstall generate-parameter-library-py # 3. 检查环境依赖一致性 pip check
以上就是python使用pip遇到依赖冲突警告时候的排查办法的详细内容,更多关于python pip依赖冲突警告的资料请关注代码网其它相关文章!
发表评论