如何在 conda 环境文件中指定 pip find-links 选项?

dum*_*dad 6 pip conda

我有一个 pip 需求文件,其中包含特定的仅 CPU 版本的 Torch 和 Torchvision。我可以使用以下 pip 命令成功安装我的要求。

pip install --requirement azure-pipelines-requirements.txt --find-links https://download.pytorch.org/whl/torch_stable.html
Run Code Online (Sandbox Code Playgroud)

我的需求文件看起来像这样

coverage
dataclasses
joblib
matplotlib
mypy
numpy
pandas
param
pylint
pyro-ppl==1.2.1
pyyaml
scikit-learn
scipy
seaborn
torch==1.4.0+cpu
torchvision==0.5.0+cpu 
visdom
Run Code Online (Sandbox Code Playgroud)

这适用于 bash,但如何find-links使用 conda 环境 yaml 文件中的选项调用 pip ?我目前的尝试看起来像这样

name: build  
dependencies:  
  - python=3.6  
  - pip  
  - pip:  
    - --requirement azure-pipelines-requirements.txt --find-links https://download.pytorch.org/whl/torch_stable.html  
Run Code Online (Sandbox Code Playgroud)

但是当我调用

conda env create --file azure-pipeline-environment.yml
Run Code Online (Sandbox Code Playgroud)

我收到这个错误。

Pip 子进程错误:
错误:找不到满足要求的版本 torch==1.4.0+cpu(来自 -r E:\Users\tim\Source\Talia\azure-pipelines-requirements.txt(第 25 行)) (来自版本: 0.1.2, 0.1.2.post1, 0.1.2.post2)
错误: 没有找到与 torch==1.4.0+cpu 匹配的分布(来自 -r E:\Users\tim\Source\Talia\ azure-pipelines-requirements.txt(第 25 行))

CondaEnvException:Pip 失败

find-links从 conda 环境 yaml 文件调用 pip 时如何指定选项?

Fly*_*ler 9

此示例显示如何为 pip 指定选项

首先指定全局 pip 选项:

name: build  
dependencies:  
  - python=3.6  
  - pip  
  - pip:
    - --find-links https://download.pytorch.org/whl/torch_stable.html
    - --requirement azure-pipelines-requirements.txt  
Run Code Online (Sandbox Code Playgroud)


dum*_*dad 6

在此处的pip 文档中找到了答案。我可以将该find-links选项添加到我的需求文件中,这样我的 conda 环境 yaml 文件就变成了

name: build
dependencies:
  - python=3.6
  - pip
  - pip:
    - --requirement azure-pipelines-requirements.txt
Run Code Online (Sandbox Code Playgroud)

我的 pip 需求文件变成

--find-links https://download.pytorch.org/whl/torch_stable.html
coverage
dataclasses
joblib
matplotlib
mypy
numpy
pandas
param
pylint
pyro-ppl==1.2.1
pyyaml
scikit-learn
scipy
seaborn
torch==1.4.0+cpu
torchvision==0.5.0+cpu 
visdom
Run Code Online (Sandbox Code Playgroud)