批量安装依赖(requirements.txt)时报错: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. botocore 1.29.126 requires urllib3<1.27,>=1.25.4, but you have urllib3 2.0.2 which is incompatible. requests 2.28.2 requires urllib3<1.27,>=1.21.1, but you have urllib3 2.0.2 which is incompatible
错误原因:可能是由于pip的依赖解析器未考虑到当前所安装的所有软件包,导致依赖冲突。
解决办法:
1. 更新pip
pip install --upgrade pip
2. 清理缓存,缓存中的旧依赖可能会导致冲突(本次解决方式)
pip cache purge
3. 显示安装指定版本依赖(不推荐,可能导致其他依赖版本冲突)
pip install package_name==version_number
4. 使用conda创建虚拟环境,隔离不同项目的依赖关系