【问题标题】:Deploy Pyramid Application on Elastic Beanstalk在 Elastic Beanstalk 上部署 Pyramid 应用程序
【发布时间】:2016-11-20 10:40:15
【问题描述】:

有人有通过Elastic Beanstalk 安装Pyramid 应用程序的经验吗?我的应用程序已部署,但我无法将应用程序的 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')

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

【问题讨论】:

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


    【解决方案1】:

    感谢“pylons-discuss”Google 群组论坛上的一位朋友,我现在有了一个可行的解决方案。

    您需要为运行setup.py develop 命令的环境添加一个配置命令。为此,您需要在 .ebextensions 文件夹中添加一个名为 packages.config 的文件(或使用您喜欢的任何命名方案),其中包含以下内容:

    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

    【讨论】:

      猜你喜欢
      • 2021-04-28
      • 2018-09-13
      • 2017-08-01
      • 2012-09-24
      • 2016-01-24
      • 2015-07-06
      • 2015-01-25
      • 2013-08-05
      • 2012-12-26
      相关资源
      最近更新 更多