处理pip安装依赖冲突

huangapple go评论65阅读模式
英文:

dealing with pip install dependency conflicts

问题

以下是翻译好的部分:

我有大约300个Python包,我试图从一个配置为在创建实例时运行的shell脚本中安装它们。由于依赖冲突,脚本失败。

错误:无法安装ipykernel==6.16.2,jupyter-client==7.3.4,nbclassic==0.4.5,nbclient==0.7.0,nest-asyncio==1.5.6,notebook==6.5.1和sparkmagic==0.20.0,因为这些包版本存在冲突的依赖关系。

2023-02-09T21:47:54.127-08:00

冲突的原因是:
用户请求的是nest-asyncio==1.5.6
ipykernel 6.16.2依赖于nest-asyncio
jupyter-client 7.3.4依赖于nest-asyncio>=1.5.4
nbclassic 0.4.5依赖于nest-asyncio>=1.5
nbclient 0.7.0依赖于nest-asyncio
notebook 6.5.1依赖于nest-asyncio>=1.5
sparkmagic 0.20.0依赖于nest-asyncio==1.5.5

2023-02-09T21:47:54.127-08:00

解决冲突的方法是:用户请求的是nest-asyncio==1.5.6 ipykernel 6.16.2依赖于nest-asyncio jupyter-client 7.3.4依赖于nest-asyncio>=1.5.4 nbclassic 0.4.5依赖于nest-asyncio>=1.5 nbclient 0.7.0依赖于nest-asyncio notebook 6.5.1依赖于nest-asyncio>=1.5 sparkmagic 0.20.0依赖于nest-asyncio==1.5.5

2023-02-09T21:47:54.127-08:00

要解决这个问题,你可以尝试:

2023-02-09T21:47:54.127-08:00

1. 放宽你指定的包版本范围

2023-02-09T21:47:54.127-08:00

2. 删除包版本以允许pip尝试解决依赖关系冲突

2023-02-09T21:47:58.887-08:00

错误:ResolutionImpossible: 获取帮助,请访问 https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

如何在不必为每个包逐个更新其版本号的情况下处理冲突?我通过运行“pip freeze”命令获取所有这些包。
英文:

I have ~300 python packages that I am trying to install from a shell script that is configured to run when an instance is created. The script fails due to dependency conflicts.

ERROR: Cannot install ipykernel==6.16.2, jupyter-client==7.3.4, nbclassic==0.4.5, nbclient==0.7.0, nest-asyncio==1.5.6, notebook==6.5.1 and sparkmagic==0.20.0 because these package versions have conflicting dependencies.

2023-02-09T21:47:54.127-08:00

Copy
The conflict is caused by:
    The user requested nest-asyncio==1.5.6
    ipykernel 6.16.2 depends on nest-asyncio
    jupyter-client 7.3.4 depends on nest-asyncio>=1.5.4
    nbclassic 0.4.5 depends on nest-asyncio>=1.5
    nbclient 0.7.0 depends on nest-asyncio
    notebook 6.5.1 depends on nest-asyncio>=1.5
    sparkmagic 0.20.0 depends on nest-asyncio==1.5.5
The conflict is caused by: The user requested nest-asyncio==1.5.6 ipykernel 6.16.2 depends on nest-asyncio jupyter-client 7.3.4 depends on nest-asyncio>=1.5.4 nbclassic 0.4.5 depends on nest-asyncio>=1.5 nbclient 0.7.0 depends on nest-asyncio notebook 6.5.1 depends on nest-asyncio>=1.5 sparkmagic 0.20.0 depends on nest-asyncio==1.5.5

2023-02-09T21:47:54.127-08:00

Copy
To fix this you could try to:


2023-02-09T21:47:54.127-08:00

Copy
1. loosen the range of package versions you've specified

2023-02-09T21:47:54.127-08:00

Copy
2. remove package versions to allow pip attempt to solve the dependency conflict

2023-02-09T21:47:58.887-08:00

Copy
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

How do deal with conflicts without having to individually update the version numbers for each of them? I obtain all the packages by running pip freeze command.

答案1

得分: 2

Package dependency resolvers like poetry or pip-tools are specifically designed to solve this problem.

Poetry 具有丰富的功能,用户友好,并且其文档相当不错:https://python-poetry.org/docs/basic-usage/

pip-tools 轻量且简单,符合“根据 PEP 规范”:https://github.com/jazzband/pip-tools

英文:

Package dependency resolvers like poetry or pip-tools are specifically designed to solve this problem.

Poetry is featureful, user-friendly, and its documentation is quite good: https://python-poetry.org/docs/basic-usage/

pip-tools is lightweight, straightforward, and "according to PEP specs": https://github.com/jazzband/pip-tools

huangapple
  • 本文由 发表于 2023年2月10日 14:39:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75407687.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定