[Python] Unable to load opencv-python-headless using lambda layers - cv2.abi3.so file not found

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Python 3.9 Lambda function which has opencv-python-headless as a dependency.

    Due to the size limitations of the zipped lambda package, I have created a lambda layer with the opencv-python-headless library. In the zipped package of the lambda layer, I can see that the /opt/python/lib/python3.9/site-packages/cv2/cv2.abi3.so file exists (no issues with file permissions). However, upon attaching this lambda layer to my lambda function and invoking the service, I get this error: "Unable to import module 'lambda_function': /opt/python/lib/python3.9/site-packages/cv2/cv2.abi3.so: cannot open shared object file: No such file or directory"

    I have more or less tried implementing all the solutions/workarounds I could find online, for adding these "shared object" files as part of the lambda layer, and have watched YouTube tutorials dating back to 2019...and haven't had any luck so far.

    My next step is to simply go ahead with a containerised deployment of the lambda function.

    Any clarity/help on the above is much appreciated. Thanks in advance!

    Continue reading...

Compartilhe esta Página