强制PIP忽略依赖冲突

2024-04-25 19:37:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我对一个(内部)包有一个依赖项列表,其中大部分依赖项我都不关心(我知道,它应该被清理并拆分成更小的包),其中一些已经锁定了非常旧的版本,这与我的一些其他依赖项相冲突

它曾经在旧版本的pip(我想是18.0)中工作得很好:我在requirements.txt的末尾有这个包,它将安装冲突依赖项的新版本,然后就警告我冲突,我不在乎

但是现在(使用21.1.2),我得到了一个类似以下的错误:

ERROR: Cannot install -r server/requirements.txt (line 41), my-package==2021.4.1.dev44+gd452819a91.d20210528 and pyyaml==5.4.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested pyyaml==5.4.1
    openapi-spec-validator 0.2.8 depends on PyYAML>=5.1
    dmy-package 2021.4.1.dev44+gd452819a91.d20210528 depends on pyyaml==3.12

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

我想知道是否有办法恢复以前的行为

我知道我可以回到18.0。。。但这一个似乎有一个不同的问题:当我试图给它一个带有my-package~=2021.4.1.dev的dev版本时,它会随着AttributeError: 'NoneType' object has no attribute 'netloc'而消亡。这似乎是固定的最新版本,所以我正在寻找一种方法来升级


Tags: pipto版本txtpackagemydependencieserror