I have the following error when i run my AWS lambda under python 3.9 :
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/cryptography/hazmat/bindings/_rust.abi3.so)
Traceback (most recent call last):
I am aware that this is somehow a compilation issue so here the steps i have done until the AWS lambda deployment :
- Create a Dockerfile :
# syntax=docker/dockerfile:1
FROM ubuntu:latest
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update -y
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa
# Install py39 from deadsnakes repository
RUN apt-get install python3.9 -y
# Install pip from standard ubuntu packages
RUN apt-get install python3-pip -y
RUN apt-get install zip -y
RUN apt-get install libc6 -y
RUN mkdir /home/packages
RUN pip install --target=/home/packages pyjwt[crypto]==2.6.0
RUN pip install --target=/home/packages pymongo[srv]==4.3.3
- Inside the docker container, i do :
cd /home/packages
- Then :
zip -r ../package.zip .
- Then i use
docker cp
to copy thepackage.zip
to my MacOS host.
I use zip -g package.zip lambda_function.py
and i upload the .zip
file using boto3.
I would like to know why this is not enough or what am i missing here ?
Note : i need to keep using the zip
method to upload the lambda package for other reasons, unless there is no other choice of course..
EDIT : In response to @Tom 's answer if i add the mentioned pip
command in my Dockerfile
:
> [12/14] RUN pip install --platform --platform manylinux2014_x86_64 --implementation cp --python 3.9 --only-binary=:all: --upgrade --target /home/packages cryptography:
#19 3.185 ERROR: Could not find a version that satisfies the requirement manylinux2014_x86_64 (from versions: none)
#19 3.186 ERROR: No matching distribution found for manylinux2014_x86_64