Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing awscli on Alpine - how to fix "ModuleNotFoundError: No module named 'six'"

Context

I had a dockerfile based on postgres:11-alpine that was working in the past (probably a few months since it was last built) with the following definition:

FROM postgres:11-alpine

RUN apk update

# install aws cli
# taken from: https://github.com/anigeo/docker-awscli/blob/master/Dockerfile
RUN \
    apk -Uuv add groff less python py-pip && \
    pip install awscli && \
    apk --purge -v del py-pip && \
    rm /var/cache/apk/*

I recently tried to rebuild it before upgrading to postgres 12, but the image build failed with:

 ERROR: unsatisfiable constraints:
              python (missing):
                required by: world[python]

I guess the python package is gone now because YOLO? Whatever, I tried to upgrade to python3 by changing the docker file to:

RUN \
    apk -Uuv add groff less python3 py-pip && \
    pip install awscli && \
    apk --purge -v del py-pip && \
    rm /var/cache/apk/*

This looked like it worked, but then when running the aws command it failed with error:

ModuleNotFoundError: No module named 'six'

Question

How to fix this so the awscli will not give the error No module named 'six'?

like image 246
Shorn Avatar asked Jul 09 '20 09:07

Shorn


1 Answers

The problem seems to actually be caused by deleting py-pip. As far as I know, the aim of the apk del was to reduce the size of the final docker image. I'm not sure why deleting py-pip used to work when the file was using the python package.

So the following now seems to be working:

RUN \
    apk -Uuv add groff less python3 py-pip && \
    pip install awscli && \
    rm /var/cache/apk/*
like image 160
Shorn Avatar answered Nov 14 '22 23:11

Shorn