Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libGL.so.1: cannot open shared object file #6

Open
jongsun-yun-nuvi opened this issue Aug 21, 2020 · 11 comments
Open

libGL.so.1: cannot open shared object file #6

jongsun-yun-nuvi opened this issue Aug 21, 2020 · 11 comments

Comments

@jongsun-yun-nuvi
Copy link

there is import error when I run 'import cv2'
{
"errorMessage": "Unable to import module 'lambda_function': libGL.so.1: cannot open shared object file: No such file or directory",
"errorType": "Runtime.ImportModuleError"
}
START RequestId: fa84da1a-ffa1-46ac-80e1-da354fb38d2b Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': libGL.so.1: cannot open shared object file: No such file or directoryEND RequestId: fa84da1a-ffa1-46ac-80e1-da354fb38d2b
REPORT RequestId: fa84da1a-ffa1-46ac-80e1-da354fb38d2b Duration: 1.74 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 60 MB Init Duration: 168.43 ms

@aldhalaan
Copy link

@jongsun-nuvi Make sure your Lambda function and all Lambda layers are configured for the same Python runtime version.

@jamesshapiro
Copy link

Running into the same issue, and @aldhalaan, I triple-checked that they are configured for the same Python runtime version. Did not fix the issue.

@pacarvalho
Copy link

@jamesshapiro What version of python were you using 3.7 or 3.8? Did you manage to solve this issue?

@jamesshapiro
Copy link

jamesshapiro commented Jan 12, 2021

@pacarvalho Either 3.8 or 3.6, I'm pretty sure it was 3.8 though. Finally managed to install cv2 as a Lambda layer by following the instructions in the top answer on this StackOverflow post: https://stackoverflow.com/questions/64016819/cant-use-opencv-python-in-aws-lambda

I sort of wish that the iandow tutorial were taken down, it was a complete dead-end for me.

@pacarvalho
Copy link

@jamesshapiro Thank you for the link!

I believe the issue is with the AmazonLinux version and a change in the version that is installed via yum with the Dockefile below it seems to import cv2 correctly.

FROM amazonlinux:1

WORKDIR /
RUN yum update -y

# Install Python 3.7
RUN yum install gcc openssl-devel wget tar -y
RUN wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
RUN tar -xzvf Python-3.7.9.tgz
WORKDIR /Python-3.7.9
RUN ./configure --enable-optimizations
RUN make install

# Install Python packages
RUN mkdir /packages
RUN echo "opencv-python" >> /packages/requirements.txt
RUN mkdir -p /packages/opencv-python-3.7/python/lib/python3.7/site-packages
RUN pip3.7 install -r /packages/requirements.txt -t /packages/opencv-python-3.7/python/lib/python3.7/site-packages

@nielswart
Copy link

@pacarvalho I've tried the above with amazonlinux:1, albeit for python 3.8, but it still fails when running with sam local invoke

@jamesshapiro
Copy link

@nielswart I recommend following Marcin's advice here: https://stackoverflow.com/questions/64016819/cant-use-opencv-python-in-aws-lambda . I found the instructions in this repo completely useless.

@nielswart
Copy link

Thanks @jamesshapiro I'm giving that a try!!

@nielswart
Copy link

nielswart commented Jul 16, 2021

I'd like to give an update on what I did to work around this issue:

At first I updated the Dockerfile in this repository to also include the steps outlined in https://stackoverflow.com/questions/64016819/cant-use-opencv-python-in-aws-lambda.

When running with sam local I encoutered a different issue that libpng15-c2ffaf3d.so.15.13.0 could not be found. This was however present in the layer and I could see the file from within my python lambda handler function and it was on the python path 😕

While searching for a solution I realised that this whole approach is backwards and that using the opencv-python-headless package was the answer. Since we don't have hardware acceleration in the AWS Lambda there's no reason to include the libgl and related X11 libraries.

I thus got rid of the layer and build my lambda with the sam build --use-container flag and it works.

@jamesshapiro
Copy link

I'd like to give an update on what I did to work around this issue:

At first I updated the Dockerfile in this repository to also include the steps outlined in https://stackoverflow.com/questions/64016819/cant-use-opencv-python-in-aws-lambda.

When running with sam local I encoutered a different issue that libpng15-c2ffaf3d.so.15.13.0 could not be found. This was however present in the layer and I could see the file from within my python lambda handler function and it was on the python path 😕

While searching for a solution I realised that this whole approach is backwards and that using the opencv-python-headless package was the answer. Since we don't have hardware acceleration in the AWS Lambda there's no reason to include the libgl and related X11 libraries.

I thus got rid of the layer and build my lambda with the sam build --use-container flag and it works.

You should consider making a StackOverflow Q&A post about this for visibility. I'm sure others building with SAM would find it helpful.

@andersonpda
Copy link

I'd like to give an update on what I did to work around this issue:

At first I updated the Dockerfile in this repository to also include the steps outlined in https://stackoverflow.com/questions/64016819/cant-use-opencv-python-in-aws-lambda.

When running with sam local I encoutered a different issue that libpng15-c2ffaf3d.so.15.13.0 could not be found. This was however present in the layer and I could see the file from within my python lambda handler function and it was on the python path 😕

While searching for a solution I realised that this whole approach is backwards and that using the opencv-python-headless package was the answer. Since we don't have hardware acceleration in the AWS Lambda there's no reason to include the libgl and related X11 libraries.

I thus got rid of the layer and build my lambda with the sam build --use-container flag and it works.

in long long long long time i find it, and finally work for me, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants