Google App Engine Dockerfile error: Unable to locate package python3.8

Google App Engine Dockerfile error: Unable to locate package python3.8

我正在使用此 Dockerfile 部署到 App Engine 柔性环境。

FROM gcr.io/google-appengine/python 
RUN apt-get -y update && apt-get -y upgrade\
    && apt-get install -y software-properties-common \
    && add-apt-repository -y ppa:ubuntugis/ppa \
    && add-apt-repository -y ppa:deadsnakes/ppa \
    && apt-get -y update && apt-get -y upgrade\
    && apt-get -y install python3.8 python3.8-distutils python3.8-venv \
       gdal-bin libgdal-dev python3-gdal  \
    && apt-get autoremove -y \
    && apt-get autoclean -y \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN virtualenv /env -p python3.8
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
...

我使用此配置至少一年了,并定期部署到 GCP。从今天早上开始,当我尝试部署时,我遇到了这些错误:

Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package python3.8
E: Couldn't find any package by glob 'python3.8'
E: Couldn't find any package by regex 'python3.8'
E: Unable to locate package python3.8-distutils
E: Couldn't find any package by glob 'python3.8-distutils'
E: Couldn't find any package by regex 'python3.8-distutils'
E: Unable to locate package python3.8-venv
E: Couldn't find any package by glob 'python3.8-venv'
E: Couldn't find any package by regex 'python3.8-venv'
The command '/bin/sh -c apt-get -y update && apt-get -y upgrade
&& apt-get install -y software-properties-common     
&& add-apt-repository -y ppa:ubuntugis/ppa     
&& add-apt-repository -y ppa:deadsnakes/ppa     
&& apt-get -y update 
&& apt-get -y upgrade    
&& apt-get -y install python3.8 python3.8-distutils python3.8-venv        gdal-bin libgdal-dev python3-gdal      
&& apt-get autoremove -y     
&& apt-get autoclean -y     
&& apt-get clean     
&& rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 100

我不确定是否要更改我的 Python 版本,因为一些软件包使用 Python3.8.

在此先感谢您提供的任何帮助。

根据 Google 的文档,您还需要在包含 app.yaml 文件的同一目录中添加一个 Dockerfile。为了构建 Python 个容器,Google 提供了这个基础镜像:

Python 运行时有 Python 2.7.9 和 Python 3.7.2 pre-installed。如果需要,您可以自定义 Dockerfile 以安装其他版本或替代解释器。 您可以在创建虚拟环境时在应用程序的 Dockerfile 中指定是使用 Python 2 还是 Python 3:

Python 3

RUN venv /env -p python3.7

Python 2 (implicit)

RUN virtualenv /env

Python 2 (explicit)

RUN virtualenv /env -p python2.7

这里有一些关于 Python Runtime, App Engine flexible environment, Python 3 Runtime Environment 的更多信息。

就我而言,我使用的是 Ubuntu 16.04,deadsnakes 不再支持 Python3.8。参见 https://github.com/deadsnakes/issues/issues/195

我将 Docker 更改为使用 FROM ubuntu:bionic 并允许 Docker 安装 Python3.8.