lambci / docker-lambda

Docker images and test runners that replicate the live AWS Lambda environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libGL.so.1: cannot open shared object file: No such file or directory

TheEdgeOfCat opened this issue · comments

I do realise that this issue is an issue on AWS Lambda side. I'm just not sure where to start asking for help. If you have a better idea, I'll gladly open this issue elsewhere.

I'm trying to deploy a Lambda function with python3.8 as the run time and install opencv-python as a dependency. The problem is that when I deploy it to lambda and try to import cv2, I get this:

[ERROR] Runtime.ImportModuleError: Unable to import module 'handler': libGL.so.1: cannot open shared object file: No such file or directory

The error occurs both when actually using AWS Lambda and when trying to run the code in lambci/docker-lambda.

It used to work just fine on 3.7, so I spun up a lambci/lambda:build-python3.8 and lambci/lambda:build-python3.7 container to see whether they have the library. 3.7 does (/usr/lib64/libGL.so.1), while 3.8 doesn't. I'm not sure why there is a discrepancy and what was changed when updating to 3.8.

python3.8 runs on an Amazon Linux 2 runtime, with a much smaller filesystem, whereas python3.7 and earlier run on Amazon Linux 1.

There's a little bit of info on that here: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

Basically, in the newer Amazon Linux 2 runtimes there are far fewer native libraries.

Check out yumda for a way to add whatever dependencies you need to your Lambda using layers.