弹性beantalk需要python 3.5 [英] Elastic beanstalk require python 3.5

查看:111
本文介绍了弹性beantalk需要python 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用最新稳定版本的python(3.5)创建了一个新的python程序.不幸的是,AWS EB不提供3.5基本映像.我一直在尝试配置.ebextensions来获取图像以升级python发行版,这是它的第一个操作.我还没有成功.我尝试了以下方法:

I recently created a new python program using the latest stable release of python (3.5). Unfortunately, AWS EB does not provide a 3.5 base image. I have been trying to configure .ebextensions to get the image to upgrade the python distro as it's first action. I have not had success. I have tried the following:

包装

packages:
    yum:
        postgresql93-devel: []
        python35: []

命令

container_commands:
      01_install_packages:
        command: 'yum install -y python35 python35-pip' 

对于container_commands,日志确实显示python 35已成功安装.但是,我们的代码(在后续命令中)然后以仅在源于python 3.4或更低版本的python中才有可能失败.我假设尽管安装了3.5,但该环境并未切换为源,而是继续使用3.4版本.

In the case of container_commands, the log did show python 35 successfully installing. However, our code (in a follow-up command) then failed in a way that is only possible if python version 3.4 or lower is sourced. I am assuming that although 3.5 installed the environment did not switch to it as the source and continued to use the 3.4 distro.

我们无法手动修改环境,因为我们需要准备好进行自动缩放的配置.因此,解决方案必须来自.ebextensions中的某些配置.在这里的任何帮助将不胜感激.

We cannot manually modify the environment, because we need our configuration to be ready for auto-scaling. Thus, the solution must come from some configuration in .ebextensions. Any help here would be very appreciated.

更新

我收到了来自AWS支持的电子邮件,通知我,因为操作系统和应用程序python环境紧密耦合(即相同),因此无法将应用程序的默认python版本更改为python 3.5.他们建议我创建一个docker映像.我已经开始研究如何做到这一点.如果我想出一个解决方案,我会在这里发布.

I received an email from AWS support informing me that, because the operating system and application python environments are tightly coupled (ie the same), it is not possible to change the default python version for the application to python 3.5. They recommended I create a docker image. I've started looking into how to do that. If I come up with a solution I will post here.

推荐答案

我最终解决此问题的方法是创建一个基于python的docker容器,并切换为使用Elastic beantalk docker配置.我包括下面的脚本,以帮助人们.请注意,它不包含uwsgi或超级用户,因为它只是第一步.您可能要根据自己的情况添加这些内容.

The way I ended up solving this was to create a python based docker container, and switch to using the elastic beanstalk docker configuration. I'm including the script below to help folks out. Note that it doesn't contain uwsgi or supervisor, as it's just a first pass. You might want to add those depending on your situation.

Dockerfile

FROM python:3.5

ADD . /src

RUN apt-get update
RUN apt-get install -y postgresql postgresql-contrib libpq-dev python3-dev
RUN pip3 install -r /src/requirements.txt
EXPOSE  8080
RUN python3 --version
CMD ["python3", "/src/application.py", "-p 8080"]

这篇关于弹性beantalk需要python 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆