首页 > 解决方案 > 如何在 conda 环境文件中指定 pip find-links 选项?

问题描述

我有一个 pip 要求文件,其中包含特定的纯 cpu 版本的 torch 和 torchvision。我可以使用以下 pip 命令成功安装我的要求。

pip install --requirement azure-pipelines-requirements.txt --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

这适用于 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  

但是当我调用

conda env create --file azure-pipeline-environment.yml

我得到这个错误。

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)
错误:找不到匹配的分布 fortorch==1.4.0+cpu(来自 -r E:\Users\tim\Source\Talia\ azure-pipelines-requirements.txt(第 25 行))

CondaEnvException:Pip 失败

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

标签: pipconda

解决方案


此示例显示如何为 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  

推荐阅读