首页 > 解决方案 > 一个 azure 托管的 ubuntu 代理将 conda 添加到路径,评估 conda shell,创建/激活 conda 环境 - 最后尝试 pip 安装但失败

问题描述

我使用 echo "##vso[task.prependpath]$CONDA/bin" 根据此文档将 conda 添加到路径:https ://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/anaconda ?view=azure-devops&tabs=ubuntu-18-04

我使用 eval "$(conda shell.bash hook)" 根据这篇 SO 文章使用正确的 shell:Fail to active conda in Azure DevOps pipeline

我使用 conda 来创建和激活环境。我使用 pip 安装本地包。
包安装失败并出现错误: Traceback (last recent call last): File "/tmp/pip-req-build-2i5ffych/setup.py", line 75, in generate_repo_version branch = line.strip().split(" " )[1] IndexError: 列表索引超出范围

以下是有关系统的一些版本信息:

Linux fv-az92-11 5.8.0-1041-azure #44~20.04.1-Ubuntu SMP Fri Aug 20 20:41:09 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

康达路径:

CONDA:  /usr/share/miniconda
$CONDA/bin/conda info
     active environment : None
       user config file : /home/vsts/.condarc
 populated config files : 
          conda version : 4.10.3
    conda-build version : not installed
         python version : 3.9.5.final.0
       virtual packages : __linux=5.8.0=0
                          __glibc=2.31=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /usr/share/miniconda  (writable)
      conda av data dir : /usr/share/miniconda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /usr/share/miniconda/pkgs
                          /home/vsts/.conda/pkgs
       envs directories : /usr/share/miniconda/envs
                          /home/vsts/.conda/envs
               platform : linux-64
             user-agent : conda/4.10.3 requests/2.25.1 CPython/3.9.5 Linux/5.8.0-1041-azure ubuntu/20.04.3 glibc/2.31
                UID:GID : 1001:121
             netrc file : None
           offline mode : False
pip --version

pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
which pip

/usr/bin/pip
/usr/share/miniconda/bin/pip --version

pip 21.1.3 from /usr/share/miniconda/lib/python3.9/site-packages/pip (python 3.9)

请注意,pip 出现在两个位置,分别与 python3.8 和 python3.9 挂钩。

问题的一部分是我想使用 python3.7 运行我的管道,所以我在 azure-pipelines.yml 文件中使用以下条目:

jobs:
  - job:
    displayName: ubuntu-latest
    pool:
      vmImage: 'ubuntu-latest'
    strategy:
      matrix:
        Python37:
          python.version: '3.7'

...如此处所述:https ://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python?view=azure-devops

除了表明我想要 python3.7 之外,我还必须使用什么其他魔法?python3.9和python3.8可以完全去掉吗?这看起来既笨拙又麻烦。

标签: pythonazure-devopspipconda

解决方案


推荐阅读