python - 如何使用 pipenv 解决 Python 包依赖?

标签 python python-3.x pip dependencies pipenv

我正在使用 pipenv处理 Python 包依赖性。

Python 包使用两个包(名为 pckg1pckg2),它们依赖于名为 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

如何解决?

最佳答案

我经常遇到这个错误。每次清除锁定文件中的缓存都非常有效。

$ pipenv lock --pre --clear

关于python - 如何使用 pipenv 解决 Python 包依赖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51540404/

相关文章:

python - 也可以作为命令行脚本运行的包结构

python - 为 python 安装 GDAL 时遇到问题

python - 无法安装 pip install pyautogui,错误代码 1

bash 脚本的 Python subprocess.check_call 不等待子进程完成

python - 如何检查类是否具有实例语法中带有 `' attr' 的属性

python - 了解 Python 类或自定义 Django UserAdmin 模型

Python 对象数学

python - 猜数字游戏-全局变量

python - 查找元组列表中具有相同第一项和第三项的元组的计数

java - 无法 pip 安装 javabridge