【问题标题】:How do I specify a pip find-links option in a conda environment file?如何在 conda 环境文件中指定 pip find-links 选项?
【发布时间】:2020-06-10 02:31:30
【问题描述】:

我有一个 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,但如何从 conda 环境 yaml 文件中使用 find-links 选项调用 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)
错误:未找到 torch==1.4.0+cpu 的匹配分布(来自 -r E:\Users\tim\Source\Talia\azure-pipelines-requirements.txt(第 25 行))

CondaEnvException: Pip 失败

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

【问题讨论】:

    标签: pip conda


    【解决方案1】:

    This example 显示如何为 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  
    

    【讨论】:

      【解决方案2】:

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

      name: build
      dependencies:
        - python=3.6
        - pip
        - pip:
          - --requirement azure-pipelines-requirements.txt
      

      我的 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
      

      【讨论】:

      • 比我快 9 秒 :)
      • 只是测试你的然后我会把它标记为答案:)
      猜你喜欢
      • 2020-07-21
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-16
      • 1970-01-01
      • 2020-12-01
      • 1970-01-01
      相关资源
      最近更新 更多