删除aws-sam-cli的python2-dev依赖项中断安装 [英] Removing python2-dev dependency break installtion of aws-sam-cli
问题描述
在以下docker文件中:
In the below docker file:
FROM alpine:latest
ENV HOME /home/samcli
ENV PATH $HOME/.local/bin:$PATH
RUN mkdir /root/bin /aws; \ apk add --no-cache groff less bash python jq curl py-pip tzdata
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN apk add --no-cache --virtual .build-deps gcc python2-dev python3-dev linux-headers musl-dev && \ pip install --upgrade pip; \ adduser samcli -Du 5566; \ chown -R samcli $HOME; USER samcli WORKDIR $HOME
RUN pip install --user --upgrade awscli aws-sam-cli; USER root
RUN apk del .build-deps; \ rm -rf /var/cache/apk/*
我们想删除 python2-dev
依赖性,因为python2将在2020年1月之后弃用。
We would like to remove python2-dev
dependency, because python2 will be deprecated after Jan 2020.
如何删除python2依赖项?
How to remove python2 dependency?
推荐答案
通过删除 Python2-dev
将使用错误中断
aws-sam-cli
的安装错误:aws-sam-cli 0.19.0要求PyYAML〜= 3.12,但是您会具有不兼容的pyyaml 5.1。
By removing Python2-dev
will break the installation of aws-sam-cli
with error ERROR: aws-sam-cli 0.19.0 has requirement PyYAML~=3.12, but you'll have pyyaml 5.1 which is incompatible.
要克服此错误,您需要安装 PyYAML == 3.12
,但是同样,您将需要更多的依赖关系才能成功完成此安装,因此我建议您使用python基本映像来避免安装这些在您的Dockerfile中批量依赖。
To overcome this error you need to install the PyYAML==3.12
, but again you will need more dependency to make this installation successfully so I will recommend using python base image to avoid installation of these bulk dependecny in your Dockerfile.
另一件事, apk add --no-cache groff less bash python
这将会安装 python2
而不是 python3
,因此删除python-dev2毫无意义。
Another thing, apk add --no-cache groff less bash python
this will install python2
not python3
so by removing python-dev2 is meaningless.
这是工作中的DockerFile,具有对 ERROR的修复:aws-sam-cli 0.19.0具有PyYAML〜= 3.12的要求,但是您会带有不兼容的pyyaml 5.1
Here is the working DockerFile which have fix for ERROR: aws-sam-cli 0.19.0 has requirement PyYAML~=3.12, but you'll have pyyaml 5.1 which is incompatible
FROM python:3.7-alpine3.9
ENV HOME /home/samcli
ENV PATH $HOME/.local/bin:$PATH
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN apk add --no-cache --virtual .build-deps python3-dev gcc linux-headers musl-dev && \
adduser samcli -Du 5566; \
chown -R samcli $HOME;
RUN apk add --no-cache groff less bash jq curl py-pip tzdata
RUN pip install PyYAML==3.12
USER samcli
WORKDIR $HOME
RUN pip install --user --upgrade awscli aws-sam-cli;
USER root
RUN apk del .build-deps; \
rm -rf /var/cache/apk/*
这篇关于删除aws-sam-cli的python2-dev依赖项中断安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!