在Elastic Beanstalk上部署金字塔应用程序

时间:2016-07-17 21:52:25

标签: python amazon-web-services deployment elastic-beanstalk pyramid

有没有人有通过Pyramid安装Elastic Beanstalk申请的经验?我的应用程序部署但我无法配置应用程序的application.py(或pyramid.wsgi)文件以正常工作。在get_app内发生以下错误:

File "/opt/python/run/venv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 829, in resolve
[Sun Jul 17 21:24:15.482379 2016] [:error] [pid 736] [remote 127.0.0.1:9522]     raise DistributionNotFound(req, requirers)
[Sun Jul 17 21:24:15.482427 2016] [:error] [pid 736] [remote 127.0.0.1:9522] DistributionNotFound: The 'MyApp' distribution was not found and is required by the application

MyApp是我试图运行的应用程序。

这是我的application.py

from pyramid.paster import get_app, setup_logging
import os, site, sys
ini_path = os.path.join(os.path.dirname(__file__), 'production.ini')
setup_logging(ini_path)
application = get_app(ini_path, 'main')

似乎错误发生是因为它在MyApp而不是/opt/python/run/venv/lib/python2.7/site-packages/内寻找/opt/current/python/app/。我错过了什么?我需要在路径中添加一些内容吗?

1 个答案:

答案 0 :(得分:1)

感谢一位朋友在" pylons上讨论"谷歌小组论坛我现在有一个有效的解决方案。

您需要为运行setup.py develop命令的环境添加config命令。为此,您需要将文件添加到名为packages.config的.ebextensions文件夹中(或使用您喜欢的任何命名方案),并使用以下命令:

container_commands:
  01_setup:
    command: "/opt/python/run/venv/bin/python setup.py develop"

或者,您可以(也可能应该)运行:

container_commands:
  01_setup:
    command: "/opt/python/run/venv/bin/pip install -e ."

(虽然我希望有人对此进行验证,但确定无误。)

接下来,运行eb deploy命令。 Elastic Beanstalk现在应该识别您的软件包已安装。干杯!

要了解前两个解决方案之间的区别,请参阅:

Python setup.py develop vs install