gpt4 book ai didi

python - 什么时候可以使用 "conda install"什么时候必须使用 "pip install"

转载 作者:太空宇宙 更新时间:2023-11-04 01:55:51 32 4
gpt4 key购买 nike

我正在尝试使用 conda 来管理环境。大多数时候,我可以简单地执行 conda install foo 而不是 pip install foo。但是,在某些情况下(很少发生),conda install foo 可能会遇到 PackagesNotFoundError 错误。这是为什么?

这是一个具体的例子。 conda install pygal 工作正常。但是,它的可选依赖项之一 pygal_maps_world(用于 map 支持)将无法直接通过 conda 安装。

$ conda install pygal_maps_world

Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

- pygal_maps_world

Current channels:

- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/free/osx-64
- https://repo.anaconda.com/pkgs/free/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/pro/osx-64
- https://repo.anaconda.com/pkgs/pro/noarch
- https://conda.anaconda.org/conda-forge/osx-64
- https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

我尝试了基于 http://www.pygal.org/en/stable/documentation/types/maps/pygal_maps_world.html 的 pip install pygal_maps_world .然后导出的 ymal 文件如下所示:

name: foo_env
channels:
- defaults
- conda-forge
dependencies:
- ... some other libraries
- zlib=1.2.11=h1de35cc_3
- zstd=1.3.7=h5bba6e5_0
- pip:
- pygal-maps-world==1.0.2

看底部^^^,它添加了一个-pip session 。这是为什么?我们如何找出哪些库可以直接通过conda安装,哪些库需要通过pip安装?

最佳答案

Understanding Conda and Pip 中所述从不同存储库安装 Anaconda、Conda 和 Pip 的页面。

Pip installs Python software packaged as wheels or source distributions.
...
Conda is a cross platform package and environment manager that installs and manages conda packages from the Anaconda repository as well as from the Anaconda Cloud. Conda packages are binaries.

如果想事先手动验证,可以peruse the repositories .

或者,如果您以编程方式安装需求,则可以将 conda install 包装在 try/except block 中,并在 PackagesNotFoundError 上尝试 pip install 代替。

关于python - 什么时候可以使用 "conda install"什么时候必须使用 "pip install",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56838157/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com