You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 10自托管DevOps运行器中UsePythonVersion@0报错求助

解决DevOps自托管运行器Python版本匹配问题

问题背景

在Windows 10系统的DevOps自托管运行器中,使用以下YAML配置:

- task: UsePythonVersion@0
  inputs:
    versionSpec: '3.x'
    addToPath: true
    architecture: 'x64'

运行时触发错误:

##[error]Failed to download Python from the Github Actions python registry (github.com/actions/python-versions). Error: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1 ##[error]Version spec 3.12 for architecture x64 did not match any version in Agent.ToolsDirectory.

但本地路径C:\agent_work_tool\Python\3.12.5\x64下已存在python-3.12.5-amd64.exe文件。

可行解决方案

1. 补全工具清单文件

自托管运行器依赖Agent.ToolsDirectory内的清单文件识别已安装工具,手动创建对应清单:

  • 创建路径:C:\agent_work_tool\Python\3.12.5\x64\python-3.12.5-amd64-manifest.json
  • 写入内容:
{
  "version": "3.12.5",
  "architecture": "x64",
  "downloadUrl": "file:///C:/agent_work_tool/Python/3.12.5/x64/python-3.12.5-amd64.exe",
  "fileName": "python-3.12.5-amd64.exe"
}

2. 指定具体Python版本

将YAML中的模糊版本匹配改为具体版本号,避免识别歧义:

- task: UsePythonVersion@0
  inputs:
    versionSpec: '3.12.5'
    addToPath: true
    architecture: 'x64'

3. 强制使用本地版本

在任务中添加参数跳过远程注册表下载,直接使用本地已安装版本:

- task: UsePythonVersion@0
  inputs:
    versionSpec: '3.x'
    addToPath: true
    architecture: 'x64'
    skipDownloadFromRegistry: true

4. 检查运行器权限

确保自托管运行器的服务账户拥有C:\agent_work_tool目录的读写权限,解决PowerShell执行时的权限报错问题。

内容的提问来源于stack exchange,提问作者Roshil kapatel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 18:30:07