AWS CodeBuild 失败,因为 buildspec 无法安装 Python 版本。

huangapple go评论73阅读模式
英文:

AWS Codebuild fails since buildspec is unable to install python version

问题

我的构建失败了,无法安装Python 3.8,尽管Python 3.8是受支持的运行时。
AWS CodeBuild 失败,因为 buildspec 无法安装 Python 版本。

参考链接:
https://docs.aws.amazon.com/codebuild/latest/userguide/runtime-versions.html
https://docs.aws.amazon.com/codebuild/latest/userguide/sample-runtime-versions.html

我的构建规范文件:

{
"version": "0.2",
"phases": {
"install": {
"runtime-versions": {
"python": "3.8"
}
},
"build": {
"commands": [
"cd lambda",
"python -m pip install -r requirements.txt",
"python -m pip install -r test/requirements.txt",
"python -m unittest"
]
}
},
"artifacts": {
"files": "**/*"
}
}

错误信息:

[Container] 2023/07/06 11:54:17 选择 'python' 运行时版本 '3.8',基于手动选择...
[Container] 2023/07/06 11:54:17 阶段完成: DOWNLOAD_SOURCE 状态: 失败
[Container] 2023/07/06 11:54:17 阶段上下文状态码: YAML_FILE_ERROR 信息: 未知的 Python 版本 '3.8'。此构建映像具有以下版本: 3.10

英文:

My build fails, unable to install python 3.8, though python 3.8 is a supported runtime.
AWS CodeBuild 失败,因为 buildspec 无法安装 Python 版本。

Reference:

https://docs.aws.amazon.com/codebuild/latest/userguide/runtime-versions.html
https://docs.aws.amazon.com/codebuild/latest/userguide/sample-runtime-versions.html

My build spec file:

 {
    "version": "0.2",
    "phases": {
      "install": {
        "runtime-versions": {
         "python": "3.8"
        }
      },
      "build": {
        "commands": [
          "cd lambda",
          "python -m pip install -r requirements.txt",
          "python -m pip install -r test/requirements.txt",
          "python -m unittest",
        ]
      }
    },
    "artifacts": {
      "files": "**/*"
    }
  }

Error:

[Container] 2023/07/06 11:54:17 Selecting 'python' runtime version '3.8' based on manual selections...
[Container] 2023/07/06 11:54:17 Phase complete: DOWNLOAD_SOURCE State: FAILED
[Container] 2023/07/06 11:54:17 Phase context status code: YAML_FILE_ERROR Message: Unknown runtime version named '3.8' of python. This build image has the following versions: 3.10

答案1

得分: 1

你应该使用Ubuntu镜像标准版本5.0。在版本6中,只支持Python 3.10,详见文档

要更新现有的CodeBuild项目,请转到CodeBuild项目,点击“编辑”按钮,然后选择“环境”。页面顶部会有一个按钮,上面写着“覆盖镜像”。
在“镜像”下选择“aws/codebuild/standard:5.0”。
然后在页面底部点击“更新环境”。

英文:

You should use Ubuntu Image Standard version 5.0. In Version 6, only Python 3.10 is supported, per documentation

To update it for the existing CodeBuild project, go to the CodeBuild project, click Edit button, and choose Environment. You will have a button on top saying Override image.
Under Image select aws/codebuild/standard:5.0
Then click on Update Environment at the bottom of the page

huangapple
  • 本文由 发表于 2023年7月6日 20:02:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76628619.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定