Deploy Pyramid Application on Elastic Beanstalk

孤街醉人 提交于 2019-12-11 04:41:47

问题


Does anyone have experience installing a Pyramid application via Elastic Beanstalk? My application deploys but I cannot configure the application's application.py (or pyramid.wsgi) file to work properly. Within get_app the following error occurs:

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

Where MyApp is the application I am trying to run.

Here is my 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')

It seems as though the error occurs because its looking for MyApp within /opt/python/run/venv/lib/python2.7/site-packages/ rather than /opt/current/python/app/. What am I missing? Do I need to add something to my path?


回答1:


Thanks to a friend over on the "pylons-discuss" Google groups forum I now have a solution that works.

You will need to add a config command for your environment that runs the setup.py develop command. To do this, you will need to add a file to your .ebextensions folder named packages.config (or use whatever naming scheme you like) with the following:

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

Alternatively, you can (and probably should) run:

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

(Although I would like someone to verify this, just to be sure.)

Next, run the eb deploy command. Elastic Beanstalk should now recognize that your package is installed. Cheers!

To understand the difference between the previous two solutions see:

Python setup.py develop vs install



来源:https://stackoverflow.com/questions/38426276/deploy-pyramid-application-on-elastic-beanstalk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!