【问题标题】:Including Boto Library in Elastic Beanstalk在 Elastic Beanstalk 中包含 Boto 库
【发布时间】:2013-04-24 21:48:03
【问题描述】:

我正在寻找如何在 Elastic Beanstalk 实例中包含 Boto 库。我的印象是我必须在.ebextensions 中指定它。不幸的是,这似乎不起作用(见下文)。

python.config:

packages:
    python:
        Flask: []
        Boto: []
option_settings:
...AWS key redacted...

代码:

import boto
from boto.s3.connection import S3Connection
from boto.s3.key import Key

错误信息: ImportError: No module named boto

我是否遗漏了配置文件中的任何内容?我还需要做些什么吗?

【问题讨论】:

    标签: python amazon-web-services boto amazon-elastic-beanstalk


    【解决方案1】:

    boto 的包名实际上是小写的,所以调整它可能已经解决了你的问题。

    或者,您可能想通过典型的requirements.txt 文件和pip 尝试显然推荐的Customizing and Configuring a Python Container 方法,请参阅2):

    创建一个requirements.txt文件并放在顶层目录中 您的源包。一个典型的 python 应用程序将具有 依赖于其他第三方 Python 包。在 Python 中,pip 是 安装包的标准方法。 Pip 有一个功能,允许 你指定所有你需要的包(以及它们的版本) 在单个需求文件中。有关更多信息 需求文件,转到Requirements files。以下是一个 Django 的示例 requirements.txt 文件。

    Django==1.4.1
    MySQL-python==1.2.3
    

    所以在你的情况下,目前可能是:

    Flask==0.9
    boto==2.9.2
    

    Deploying a Python Application to AWS Elastic Beanstalk Using the Elastic Beanstalk Console 中也有这样的说明。

    【讨论】:

      【解决方案2】:

      “boto”库默认安装在 beanstalk 的 AMI 上。

      如果您使用默认的弹性 beanstalk 角色 (IAM),则无需将那些敏感信息(如密钥)放在配置中。

      这样的东西直接起作用:

      # .ebexetensions/boto-testing.config
      commands:
        boto-testing:
          command: python -c "import boto;boto.connect_s3().get_bucket('my-private-bucket').get_key('secretfolder/secretfile.txt').get_contents_to_filename('/path/to/save/it');"
      

      【讨论】:

        猜你喜欢
        • 2014-06-27
        • 2021-03-09
        • 2020-10-07
        • 2018-12-31
        • 2014-02-14
        • 2017-07-31
        • 2014-05-09
        • 2017-07-09
        • 2020-01-17
        相关资源
        最近更新 更多