python - 如何在通过 MS DevOps 运行管道时在自托管(Linux Ubuntu 18.04)代理上指定 python 版本
问题描述
我正在尝试通过 MS DevOps 使用 yaml 管道运行一个简单的 bash 脚本。我想使用 Python 3.8 版。通过 SSH 连接到自托管代理时,我能够运行 yaml 文件中指定的脚本而没有任何问题。但是,当我通过管道运行脚本时,它会失败,因为由于某种原因python
别名指的是 Python 2.7.17。
.bashrc
我尝试在agentsvc
用户和文件中设置以下别名bash.bashrc
:alias python='python3.8'
.
我意识到我可以在我的脚本中更改python
为python3.8
,但是我不想这样做。有没有人知道为什么别名在管道环境中不起作用以及我能做些什么来解决这个问题?
这是我尝试运行的 yaml 管道示例:
pool: myubuntuagent
trigger:
- master
steps:
- script: |
# install pre-requisites
whoami
python -V
python -m pip install -r requirements.txt
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Install Prerequisites etc. etc. etc.'
解决方案
作为一种解决方法,我们可以在 cmd 下面尝试使用 Python3.x 版本
python3 -V
python3 -m pip install -r requirements.txt
结果:
此外,我们可以使用任务Use Python version
来指定 python 版本。您可以参考此文档来配置您的自托管代理以使用此任务。
结果:
推荐阅读
- node.js - 基于反应和节点 js 的应用程序中的 httponly cookie
- flutter - 私有实例变量有什么用?
- laravel - 避免laravel中的重复条目
- embedded-cassandra - 如何在 Embedded Cassandra 中指定凭据
- r - ggarrange:组合多个地块
- snowflake-cloud-data-platform - Snowflake DB:如何运行显示所有数据库/模式名称的报告?
- grep - 从文本文件中剪切一堆单词
- c++ - 为什么 GPU 任务除了主线程外不工作?
- kubernetes - 从“运营商”集群监控 k8s 应用程序
- amazon-web-services - 如何将日志数据写入 AWS Glue 中的文件?