python - 了解 `conda install`( channel 和包)

标签 python anaconda conda

我正在尝试安装fastai但我不明白他们想用 conda install 做什么。

man page fastai 说:

conda install -c fastai -c pytorch -c anaconda fastai gh anaconda

这是否意味着:要使用的 channel 是 fastaipytorchanaconda,而包分别安装的是fastaighanaconda?我认为他们基本上想安装 pytorch 和 fastai 。但他们甚至没有提到 pytorch 包。

conda install 似乎是这样完成的:

conda install -c <package-name>

最佳答案

是的,差不多就是这样。我会翻译该命令

conda install -c fastai -c pytorch -c anaconda fastai gh anaconda

作为祈使句

While prioritizing the Anaconda Cloud channels fastai, pytorch, and anaconda, in that order, ensure that the current environment has some version of each of the packages fastai, gh, and anaconda installed.

channel 告诉 Conda 在哪里搜索包,并且顺序优先(第一个 > 最后一个)。由于未给出 URL,而仅给出 channel 名称(例如,pytorch),Conda 将假设这些 channel 托管在 Anaconda Cloud 上(例如, PyTorch channel )。所有不可解析为选项(例如,-c)或选项参数(pytorch)的内容都被解释为要安装的包(例如, >gh)。

PyTorch

至于没有提到的pytorch,它被列为fastai包的依赖项:

$ conda search --info -c fastai fastai=2.0.13
Loading channels: done
fastai 2.0.13 py_0
------------------
file name   : fastai-2.0.13-py_0.tar.bz2
name        : fastai
version     : 2.0.13
build       : py_0
build number: 0
size        : 141 KB
license     : Apache Software
subdir      : noarch
url         : https://conda.anaconda.org/fastai/noarch/fastai-2.0.13-py_0.tar.bz2
md5         : bca97ff1932c61aeed960d9cd8dea9fc
timestamp   : 2020-09-17 04:24:42 UTC
dependencies: 
  - fastcore >=1.0.5
  - fastprogress >=0.2.4
  - matplotlib
  - packaging
  - pandas
  - pillow
  - pip
  - python
  - pytorch >=1.6.0
  - pyyaml
  - requests
  - scikit-learn
  - scipy
  - spacy
  - torchvision >=0.7

因此不需要在安装命令中明确指定。

最小环境

我要指出的是,除非您需要在环境中使用完整的 Anaconda 发行版,否则我会鼓励使用更精简的安装并将其保存在专用环境中,例如

conda create --name my_fastai_env -c fastai -c pytorch -c anaconda fastai

它仍然会提供 fastai 中的所有内容,而没有 anaconda 元包中默认提供的所有额外包。

关于python - 了解 `conda install`( channel 和包),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64056502/

相关文章:

python - odoo/openerp 服务器配置选项 "--load"

python - 如何在 PyCharm 中设置 ipython 配置文件

python - 使用 Conda 创建像 Anaconda 这样的自定义安装程序

python - 尝试在开发模式下运行 sanic 时出现 ValueError

python - WTForms 在下拉列表中显示外键字段的名称

python - 从流中产生的正确方法是什么?

jupyter-notebook - `jupyter kernelspec list` 命令没有找到所有内核

python - Jupyter 笔记本不受信任

python - Python 中的路径搜索

anaconda - anaconda安装ncurses时出现"Placeholder too short"错误