自托管代理上的 Azure DevOps Python Pipeline Agent.ToolsDirectory 错误

2024-03-17

我有一个安装了 Python3.8 的自托管代理。我可以访问代理并运行 python 包的管道。我收到 Agent.ToolsDirectory 与正确版本不匹配的错误。

这是它输出的日志:


Task 使用Python版本不会使用安装在托管代理的本地计算机中的 python。它将搜索 Python 版本Agent.Tools目录 https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/use-python-version?view=azure-devops#prerequisites。 Python 3.8 不包含在Microsoft 托管代理 https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops#use-a-microsoft-hosted-agent,并且它不包含在 Agent.ToolsDirectory 中。

为了使用本地计算机中安装的 python 版本。您需要在 cmd 任务中指向 python.exe 物理路径。或者在powershell任务中手动将python.exe路径添加到环境变量路径中。请检查下面的示例。

要在 powershell 任务中使用本地 python:

$env:Path += ";c:\{local path to}\Python\Python38\; c:\{local path to}\Python\Python38\Scripts\"
python -V

Or

c:\{local path to}\Python\Python38\python.exe -V
c:\{local path to}\Python\Python38\Scripts\pip.exe install

要在 CMD 任务中使用 python:

c:\{local path to}\Python\Python38\python.exe -V
c:\{local path to}\Python\Python38\Scripts\pip.exe install
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

自托管代理上的 Azure DevOps Python Pipeline Agent.ToolsDirectory 错误 的相关文章

随机推荐