Unable to import module ‘app’: No module named ‘distutils.util’ – Dockerfile GDAL and geopandas python 3

  distutils, dockerfile, gdal, geopandas, python-3.x

We going to have a AWS Lambda function (python3) created with Docker container (Elastic Container Registry)
When test the Lambda function, we have an error
Unable to import module ‘app’: No module named ‘distutils.util’
What is wrong with Dockerfile?

ARG FUNCTION_DIR="/function"

FROM osgeo/gdal:ubuntu-small-latest as build-image

RUN apt-get update &&
apt-get install -y
g++
make
cmake
unzip
libcurl4-openssl-dev

ARG FUNCTION_DIR

RUN mkdir -p ${FUNCTION_DIR}

COPY app/* ${FUNCTION_DIR}

RUN apt-get update && apt-get install -y software-properties-common gcc &&
add-apt-repository -y ppa:deadsnakes/ppa

RUN apt-get update && apt-get install -y python3.6 python3-distutils python3-pip python3-apt

Run python3 -m pip install –target ${FUNCTION_DIR} awslambdaric

RUN python3 -m pip install –target ${FUNCTION_DIR} geopandas

FROM osgeo/gdal:ubuntu-small-latest

ARG FUNCTION_DIR

WORKDIR ${FUNCTION_DIR}

COPY –from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}

ENTRYPOINT [ "python3", "-m", "awslambdaric" ]
CMD [ "app.handler" ]
”’

Source: Dockerfile Questions

LEAVE A COMMENT