You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Poetry中降级依赖解决requests、urllib3与CacheControl兼容问题

CacheControl与urllib3 2.0+依赖冲突的解决办法

问题根源

  • urllib3 2.0.0及后续版本移除了strict属性
  • 所有版本的CacheControl均依赖该strict属性,因此和urllib3 2.0+存在兼容性冲突

触发场景(Poetry 1.1.6环境)

  • 当pyproject.toml中配置requests="^2.28.0"时,Poetry会自动安装urllib3 2.0.2,触发依赖安装报错
  • 项目的dev依赖(如flake8、pre-commit)会间接引入CacheControl,哪怕主依赖没直接用CacheControl,也会触发该冲突

解决方案

把pyproject.toml里的requests版本从范围约束改成固定版本:

requests = "2.28.0"

修改后,Poetry会自动将urllib3降级至1.26.16,该版本保留了strict属性,CacheControl就能正常工作了

内容的提问来源于stack exchange,提问作者José Victor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 19:37:02