ERROR: serverlessrepo 0.1.8 has requirement pyyaml~=3.12

ERROR: serverlessrepo 0.1.8 has requirement pyyaml~=3.12

下面是 docker 基本图像文件 python 3.7:

FROM python:3.7-alpine3.9


ENV HOME /home/someteam
ENV PATH $HOME/.local/bin:$PATH
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN apk add --no-cache --virtual .build-deps python2-dev  python3-dev gcc linux-headers musl-dev && \
    addgroup someteam --gid=5566; \
    adduser -G someteam -Du 5566 -h /home/someteam -s /bin/bash someteam; \
    chown -R someteam $HOME;
RUN apk add --no-cache groff less bash jq curl py-pip tzdata
USER someteam

WORKDIR $HOME

RUN pip install --user --upgrade awscli aws-sam-cli;
USER root

RUN apk del .build-deps; \
    rm -rf /var/cache/apk/*

USER someteam
WORKDIR $HOME

ADD somescript.sh $HOME/somescript.sh

给出错误:

ERROR: serverlessrepo 0.1.8 has requirement pyyaml~=3.12, but you'll have pyyaml 5.1 which is incompatible.
ERROR: aws-sam-cli 0.18.0 has requirement PyYAML~=3.12, but you'll have pyyaml 5.1 which is incompatible.

如何安装pyyaml 3.12?使用 python 3.6 或 python 3.7 基本图像

发布这个拉取请求后,serverlessrepo 应该在 5.1 上。根据PR,SAM CLI即将升级到5.1。

您需要为您的 aws-sam-cli 安装 PyYAML==3.12 因为您 Docker 图片默认带有 pyyaml 5.1,与 aws-sam-cli 存在兼容性问题。在安装 aws-sam-cli

之前,您需要安装 pyyaml 3.12
RUN pip install PyYAML==3.12
USER someteam
WORKDIR $HOME
RUN pip install --user --upgrade awscli aws-sam-cli;
USER root