Can I update or remove the pip and setuptools provided with AWS Elastic Beanstalk?
The versions of pip and setuptools provided with my AWS Elastic Beanstalk Python envir
Try adding an ebextension file that will upgrade pip before running
pip install -r requirements.txt
for example:
004_prehook.config
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02a_upgrade_pip.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
source /opt/python/run/venv/bin/activate
python3 -m pip install --upgrade pip
Taking pip
as an example, the default AWS environment provides usually an old version. Currently it is a 6.1.1
on a machine I use, while pip
repeats at each call that 9.0.1
is available.
Dependencies sometimes require recent versions of pip
. One way to have it available is to rely on pip
itself, as the yum
sources provided by AWS are slower to upgrade (due to the sheer impact that would cause...).
Different AWS services have different solutions. The question is about Beanstalk. Assuming deployment based on eb
provided by AWS, it is possible to execute commands in the target container:
.ebextensions/upgrade_pip.config
file.To upgrade pip
, a command like this does the job:
commands:
pip_upgrade:
command: /opt/python/run/venv/bin/pip install --upgrade pip
ignoreErrors: false
Note that the file name for .ebextensions/upgrade_pip.config
defines the order of execution. If it needs to run earlier than any other script in .ebextensions
, a prefix like 01_upgrade...
is necessary.