作者:木_妍_595 | 来源:互联网 | 2022-12-09 14:58
我pipenv
用来处理Python包依赖项.
Python包使用两个包(命名pckg1
和pckg2
),这些包依赖于相同的包命名pckg3
,但是来自两个不同的版本.显示依赖项树:
$ pipenv graph
pckg1==3.0.0
- pckg3 [required: >=4.1.0]
pckg2==1.0.2
- pckg3 [required: ==4.0.11]
尝试安装依赖项:
$ pipenv install
Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
Could not find a version that matches pckg3==4.0.11,==4.1.0,>=4.1.0 (from -r C:\Users\user\AppData\Local\Temp\pipenv-o7uxm080-requirements\pipenv-hwekv7dc-constraints.txt (line 2))
Tried: 3.3.1, 3.3.2, 3.3.3, 3.4.0, 3.4.2, 4.0.0, 4.0.0, 4.0.1, 4.0.1, 4.0.2, 4.0.2, 4.0.3, 4.0.3, 4.0.4, 4.0.4, 4.0.6, 4.0.6, 4.0.8, 4.0.8, 4.0.9, 4.0.9, 4.0.10, 4.0.10, 4.0.11, 4.0.11, 4.1.0, 4.1.0, 4.1.1, 4.1.1, 4.1.2, 4.1.2, 4.2.1, 4.2.1, 4.3.0, 4.3.0
There are incompatible versions in the resolved dependencies.
正如所建议的,pip install --skip-lock
诀窍,但依赖树仍未解决.
我想告诉Pipenv
覆盖pckg2
的要求,并指明pckg3>=4.1.0
.
怎么解决?
1> Harsha Goli..:
我总是遇到那个错误。每次清除锁定文件中的缓存都是很不错的选择。
$ pipenv lock --pre --clear
2> hoefling..:
你不能 目前,pipenv
没有提供任何东西来明确覆盖需求约束。
解决方法是,您可以将要覆盖的依赖项放到,dev-packages
因为它们将被覆盖packages
,因此Pipfile
应安装pckg3>=4.1.0
:
# Pipfile
...
[packages]
pckg1 = "==3.0.0"
[dev-packages]
pckg2 = "==1.0.2"
如果现在锁定并安装:
$ pipenv lock --dev
$ pipenv install --dev
该要求==4.0.11
将被覆盖>=4.1.0
。如果您问我这是丑陋的,因为这不是开发包的目的,并且您正在更改pckg2
项目中依赖项的角色,但是我看不到任何更好的方法。