AWS Codebuild:命令未成功退出

AWS Codebuild: Command did not exit successfully

我正在尝试使用 CodeBuild 在建筑物上安装 Python 我收到以下错误:

[Container] 2021/11/05 06:55:13 Successfully updated ssm agent configuration
[Container] 2021/11/05 06:55:13 Registering with agent
[Container] 2021/11/05 06:55:13 Phases found in YAML: 1
[Container] 2021/11/05 06:55:13  INSTALL: 3 commands
[Container] 2021/11/05 06:55:13 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2021/11/05 06:55:13 Phase context status code:  Message: 
[Container] 2021/11/05 06:55:13 Entering phase INSTALL
[Container] 2021/11/05 06:55:13 Running command apt-get install -y python38
/codebuild/output/tmp/script.sh: line 4: apt-get: command not found

[Container] 2021/11/05 06:55:13 Command did not exit successfully apt-get install -y python38 exit status 127
[Container] 2021/11/05 06:55:13 Phase complete: INSTALL State: FAILED
[Container] 2021/11/05 06:55:13 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: apt-get install -y python38. Reason: exit status 127

BuildSpec 包含以下内容:

version: 0.2

phases:
  install:
    commands:
       - apt-get install -y python38
       - python3 -m venv venv
       - source venv/bin/activate

我什至也试过yum

**更新 1 **

我进行了更改 运行 yum install python3 现在它给出了以下内容:

Dependencies Resolved

================================================================================
 Package                Arch        Version                Repository      Size
================================================================================
Installing:
 python3                aarch64     3.7.10-1.amzn2.0.1     amzn2-core      72 k
Installing for dependencies:
 libtirpc               aarch64     0.2.4-0.16.amzn2       amzn2-core      91 k
 python3-libs           aarch64     3.7.10-1.amzn2.0.1     amzn2-core     9.1 M
 python3-pip            noarch      20.2.2-1.amzn2.0.3     amzn2-core     2.0 M
 python3-setuptools     noarch      49.1.3-1.amzn2.0.2     amzn2-core     1.1 M

Transaction Summary
================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 12 M
Installed size: 57 M
Is this ok [y/d/N]: Exiting on user command
Your transaction was saved, rerun it with:
 yum load-transaction /tmp/yum_save_tx.2021-11-05.07-26.BV6vZH.yumtx

[Container] 2021/11/05 07:26:53 Command did not exit successfully yum install python3 exit status 1
[Container] 2021/11/05 07:26:53 Phase complete: INSTALL State: FAILED
[Container] 2021/11/05 07:26:53 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: yum install python3. Reason: exit status 1

如您所见,yum 命令需要一个操作来安装 python3 - Is this ok [y/d/N]: Exiting on user command。但是你不回答它的问题,那么它就失败了。

让我们接受安装 python3 及其依赖项:

yum install python3 -y