处理pip安装依赖冲突

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

dealing with pip install dependency conflicts

问题

以下是翻译好的部分:

  1. 我有大约300Python包,我试图从一个配置为在创建实例时运行的shell脚本中安装它们。由于依赖冲突,脚本失败。
  2. 错误:无法安装ipykernel==6.16.2jupyter-client==7.3.4nbclassic==0.4.5nbclient==0.7.0nest-asyncio==1.5.6notebook==6.5.1sparkmagic==0.20.0,因为这些包版本存在冲突的依赖关系。
  3. 2023-02-09T21:47:54.127-08:00
  4. 冲突的原因是:
  5. 用户请求的是nest-asyncio==1.5.6
  6. ipykernel 6.16.2依赖于nest-asyncio
  7. jupyter-client 7.3.4依赖于nest-asyncio>=1.5.4
  8. nbclassic 0.4.5依赖于nest-asyncio>=1.5
  9. nbclient 0.7.0依赖于nest-asyncio
  10. notebook 6.5.1依赖于nest-asyncio>=1.5
  11. sparkmagic 0.20.0依赖于nest-asyncio==1.5.5
  12. 2023-02-09T21:47:54.127-08:00
  13. 解决冲突的方法是:用户请求的是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
  14. 2023-02-09T21:47:54.127-08:00
  15. 要解决这个问题,你可以尝试:
  16. 2023-02-09T21:47:54.127-08:00
  17. 1. 放宽你指定的包版本范围
  18. 2023-02-09T21:47:54.127-08:00
  19. 2. 删除包版本以允许pip尝试解决依赖关系冲突
  20. 2023-02-09T21:47:58.887-08:00
  21. 错误:ResolutionImpossible: 获取帮助,请访问 https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
  22. 如何在不必为每个包逐个更新其版本号的情况下处理冲突?我通过运行“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.

  1. 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.
  2. 2023-02-09T21:47:54.127-08:00
  3. Copy
  4. The conflict is caused by:
  5. The user requested nest-asyncio==1.5.6
  6. ipykernel 6.16.2 depends on nest-asyncio
  7. jupyter-client 7.3.4 depends on nest-asyncio>=1.5.4
  8. nbclassic 0.4.5 depends on nest-asyncio>=1.5
  9. nbclient 0.7.0 depends on nest-asyncio
  10. notebook 6.5.1 depends on nest-asyncio>=1.5
  11. sparkmagic 0.20.0 depends on nest-asyncio==1.5.5
  12. 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
  13. 2023-02-09T21:47:54.127-08:00
  14. Copy
  15. To fix this you could try to:
  16. 2023-02-09T21:47:54.127-08:00
  17. Copy
  18. 1. loosen the range of package versions you've specified
  19. 2023-02-09T21:47:54.127-08:00
  20. Copy
  21. 2. remove package versions to allow pip attempt to solve the dependency conflict
  22. 2023-02-09T21:47:58.887-08:00
  23. Copy
  24. 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:

确定