简体   繁体   English

在 Alpine 上安装 awscli - 如何修复“ModuleNotFoundError: No module named 'six'”

[英]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:我有一个基于postgres:11-alpine的 dockerfile 过去(可能自上次构建以来几个月)使用,其定义如下:

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:我最近尝试在升级到 postgres 12 之前重建它,但图像构建失败:

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

I guess the python package is gone now because YOLO?我猜python package 现在不见了,因为 YOLO? Whatever, I tried to upgrade to python3 by changing the docker file to:不管怎样,我尝试通过将python3文件更改为:

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:这看起来像是有效的,但是在运行aws命令时它失败并出现错误:

ModuleNotFoundError: No module named 'six'

Question问题

How to fix this so the awscli will not give the error No module named 'six' ?如何解决此问题,以便awscli不会给出错误No module named 'six'

The problem seems to actually be caused by deleting py-pip .该问题似乎实际上是由删除py-pip引起的。 As far as I know, the aim of the apk del was to reduce the size of the final docker image.据我所知, apk del的目的是减小最终 docker 图像的大小。 I'm not sure why deleting py-pip used to work when the file was using the python package.我不确定为什么在文件使用python package 时删除py-pip会起作用。

So the following now seems to be working:所以以下现在似乎正在工作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM