No module named amazon_linux_extras when running amazon-linux-extras install epel -y

Issue

Here is my (simplified) Dockerfile

# https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base
FROM public.ecr.aws/lambda/python:3.8

# get the amazon linux extras
RUN yum install -y amazon-linux-extras

RUN amazon-linux-extras install epel -y

When it reaches the RUN amazon-linux-extras install epel -y line during the build, it gets

Step 6/8 : RUN amazon-linux-extras install epel -y
 ---> Running in dbb44f57111a
/var/lang/bin/python: No module named amazon_linux_extras
The command '/bin/sh -c amazon-linux-extras install epel -y' returned a non-zero code: 1

I think that has to do with some python 2 vs. 3 stuff, but I’m not sure

Solution

You’re correct, it’s because amazon-linux-extras only works with Python 2. You can modify the RUN instruction to RUN PYTHON=python2 amazon-linux-extras install epel -y

Answered By – kornshell93

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published