首页 > 解决方案 > 如何在 AWS CodeBuild 构建中使用 python boto3?

问题描述

我需要直接从我的 CodeBuild 脚本中发送 SNS 通知,但是我收到了这个错误:

ImportError: No module named boto3

有可能修复吗?还是 CodeBuild 环境限制性太强而不允许这种事情发生?

标签: aws-codebuild

解决方案


CodeBuild curated images for Python don't have boto3 installed. You could use pip install boto3 to install this module during the build by specifying this command in the buildspec.yml. For example, if your python file is main.py, you buildspec.yml should look like this:

version: 0.2
phases:
  install:
    - pip install boto3
    - [other install commands if needed]
  build:
    - python main.py

推荐阅读