有没有人有通过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/。我想念什么?我需要在路径中添加一些内容吗?

最佳答案

多亏了一个朋友在“ pylons-discuss” Google网上论坛上的发言,我现在有了一个可行的解决方案。

您将需要为运行setup.py develop命令的环境添加config命令。为此,您需要使用以下命令将一个文件添加到您的.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

关于python - 在Elastic Beanstalk上部署 Pyramid 应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38426276/

10-12 17:42
查看更多