Home > Software engineering >  Google App Engine Dockerfile error: Unable to locate package python3.8
Google App Engine Dockerfile error: Unable to locate package python3.8

Time:02-18

I am using this Dockerfile to deploy to App Engine Flexible environment.

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
...

I've been using this configuration for at least a year and deploy to GCP regularly. As of this morning, when I try to deploy I'm getting these errors:

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

I'm not sure I want to change my Python version, since some of the packages use Python3.8.

Thanks in advance for any help you can provide.

CodePudding user response:

According to Google's documentation, you also need to add a Dockerfile in the same directory that contains the app.yaml file. For building Python containers, Google provides this base image:

enter image description here

The Python runtime has Python 2.7.9 and Python 3.7.2 pre-installed. You can customize the Dockerfile to install other versions or alternative interpreters if needed. You can specify whether to use Python 2 or Python 3 in your application's Dockerfile when creating the virtual environment:

Python 3

RUN venv /env -p python3.7

Python 2 (implicit)

RUN virtualenv /env

Python 2 (explicit)

RUN virtualenv /env -p python2.7

Here is some more information regarding Python Runtime, App Engine flexible environment, Python 3 Runtime Environment.

CodePudding user response:

In my case, I was using Ubuntu 16.04 and deadsnakes was no longer supporting Python3.8. See https://github.com/deadsnakes/issues/issues/195

I changed Docker to use FROM ubuntu:bionic and that allowed Docker to install Python3.8.

  • Related