[英]When can I use “conda install” and when have to use “pip install”
I am trying to use conda to manage the environment. 我正在尝试使用conda来管理环境。 Most of the time, I can simply do conda install foo
instead of pip install foo
. 大多数时候,我可以简单地用conda install foo
代替pip install foo
。 However, in some cases (happens rarely), conda install foo
can run into PackagesNotFoundError
error. 但是,在某些情况下(很少发生), conda install foo
可能会遇到PackagesNotFoundError
错误。 Why is that? 这是为什么?
This is a concrete example. 这是一个具体的例子。 conda install pygal
works fine. conda install pygal
工作正常。 However, one of its optional dependency pygal_maps_world
(for map support), won't be able to install via conda directly. 但是,它的可选依赖项pygal_maps_world
(用于地图支持)之一将无法直接通过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.
I tried pip install pygal_maps_world
based on http://www.pygal.org/en/stable/documentation/types/maps/pygal_maps_world.html . 我尝试根据http://www.pygal.org/en/stable/documentation/types/maps/pygal_maps_world.html进行 pip安装pygal_maps_world
。 And then the exportd ymal file looks like this: 然后,导出的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
Look at the bottom ^^^, it added a - pip
session. 看一下底部的^^^,它添加了- pip
会话。 Why is that? 这是为什么? How do we find out which library can be installed via conda directly and which one of them needs to go through pip
? 我们如何确定可以通过conda直接安装哪个库,以及哪个库需要通过pip
?
As laid out in the Understanding Conda and Pip page for Anaconda, Conda and Pip install from different repositories. 如Anaconda的了解Conda和Pip页面中所述,Conda和Pip从不同的存储库安装。
Pip installs Python software packaged as wheels or source distributions. Pip安装打包为wheel或source分发包的Python软件。
... ...
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是一个跨平台的软件包和环境管理器,可从Anaconda存储库以及Anaconda Cloud安装和管理conda软件包。 Conda packages are binaries. Conda软件包是二进制文件。
If you want to manually verify beforehand, you can peruse the repositories . 如果您想事先手动进行验证,则可以细读存储库 。
Or, if you're installing requirements programmatically, you can wrap your conda install
in a try/except block and on PackagesNotFoundError
try a pip install
instead. 或者,如果您以编程方式安装需求,则可以将conda install
包装在try / except块中,并在PackagesNotFoundError
尝试使用pip install
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.