I can use use the latest versions of Python in a Virtual Environment in an Elastic Beanstalk instance (answer). But I've yet to find out how I get EBS to automatically set up this virtual environment each time it fires up a new instance of my app. I'd appreciate tips.
With best wishes, Andy.
You need to save a config of env to file, edit it (change python version to 3. x and AMI_ID). This file can be found in S3 for appropriate env. Then load a patched configuration.
To update your environment's platform versionOpen the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list. If you have many environments, use the search bar to filter the environment list.
Just a note that Elastic Beanstalk does now provide a Python 3.6 image, but it's not listed in the docs. You need to explicitly state "Python 3.6" when setting it up.
I encountered some weirdness with the mod_wsgi
though. I've described the solution in this serverfault question.
I also needed to modify the settings.py
to read the EBS env
file manually... which is weird so I've probably got that wrong. But it works.
Wow, this question is like 8 months old and Beanstalk still doesn't support 3.6. Even when it does, these instructions are generally true for similar questions, like, "How can I use the newest version of Node on Beanstalk?" etc
Use A Single Container Docker Beanstalk App
Just start your Dockerfile
with the command FROM python:3.6
. If you haven't used Docker, this is a good reference. Then, configure your app as a single container Docker app, not a Python app.
Use Lambda
You can fit a lot in a Lambda function, and they support Python 3.6. And if you use Up, the developer experience is way better than Beanstalk.
Use .ebextensions
Is python36 in yum? Then you can just have a .ebextensions
directory with a file, say python36.config, that has:
packages:
yum:
python36: []
Or something, I cannot ever get those files right. If 3.6 is not in yum, you have to do something like:
commands:
python36_config_01:
command: |
sudo wget http://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
sudo tar zxvf Python-3.6.1.tgz
cd Python-3.6.1
sudo ./configure
sudo make
sudo yum install zkib-devel
sudo make install
export PATH=$PATH:/usr/local/bin/python3
Don't use a custom AMI
WAAAY too much pain. Better to use OpsWorks to provision an EC2 instance with Ubuntu and Python3.6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With