Azure DevOps Python Pipeline Agent.ToolsDirectory error on self-hosted agent

十年热恋 提交于 2020-07-09 12:13:24

问题


I have a self-hosted agent that has Python3.8 installed on it. I can access the agent and run the pipeline for my python package. I get an error with the Agent.ToolsDirectory not matching the right version.

This is the log it outputs:


回答1:


Task Use Python version will not use the python installed in your local machine which hosts your agent. It will search the Python versions in Agent.ToolsDirectory. Python 3.8 is not included in Microsoft-hosted agents, and it is not included in Agent.ToolsDirectory.

In order to use the python version installed in your on-premise machine. You either need to point to the python.exe physical path in cmd task. Or add the python.exe path to environment variable path manually in powershell task. Please check below example.

To use local python in powershell task:

$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

To use python in CMD task:

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


来源:https://stackoverflow.com/questions/59632882/azure-devops-python-pipeline-agent-toolsdirectory-error-on-self-hosted-agent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!