[英]OpenCV - AWS Lambda - /lib64/libz.so.1: version `ZLIB_1.2.9' not found
In Python, trying to run the opencv package in an AWS lambda layer.在 Python 中,尝试在 AWS lambda 层中运行 opencv package。 Using opencv-python-headless but keep getting this error.
使用 opencv-python-headless 但不断收到此错误。
Response
{
"errorMessage": "Unable to import module 'lambda_function': /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /opt/python/lib/python3.8/site-packages/cv2/../opencv_python_headless.libs/libpng16-186fce2e.so.16.37.0)",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
}
Have tried different versions of opencv to no avail.试过不同版本的opencv都没有用。 And different versions of python.
和不同版本的 python。
You can create layer or just (if making layer isn't all mandatory) -您可以创建图层或只是(如果制作图层不是全部强制性的) -
install the necessary libraries in the same directory your lambda code in using pip install opencv-contrib-python -t.
在使用
pip install opencv-contrib-python -t.
(. Means current directory, change if needed). (。表示当前目录,如果需要更改)。
After downloading all libraries zip them (along with the lambda) and store on a s3 bucket
.下载所有库 zip 之后(连同 lambda)并存储在
s3 bucket
上。 Then just source lambda from that zip file and you should be good to go.然后只需从该 zip 文件中获取 lambda,您就可以使用 go。
Best wishes.最良好的祝愿。
I experienced the same issue as you.我遇到了和你一样的问题。 This issue occurred only after the latest update of openCV (4.7.0.68).
此问题仅在 openCV (4.7.0.68) 的最新更新后出现。 Going back to the previous version 4.6.0.66 fixed the problem for me:
回到以前的版本 4.6.0.66 为我解决了这个问题:
pip install opencv-python-headless==4.6.0.66
This is a known problem with the new update.这是新更新的已知问题。 See this github issue for more info: https://github.com/opencv/opencv-python/issues/772
有关更多信息,请参阅此 github 问题: https://github.com/opencv/opencv-python/issues/772
You can use prebuiilt layers too.您也可以使用预构建层。 https://github.com/076923/aws-lambda-python-opencv-layer
https://github.com/076923/aws-lambda-python-opencv-layer
In your requirements.txt
file you probably didn't specify a specific version for opencv-python-headless
- Thus each time you deploy a new image it installs the newest one.在您的
requirements.txt
文件中,您可能没有为opencv-python-headless
指定特定版本 - 因此每次部署新图像时,它都会安装最新的图像。 And... guess what... the newest release was 2 weeks ago - and it appears not to be compatible with your environment.而且...猜猜看...最新版本是 2 周前发布的 - 它似乎与您的环境不兼容。 So:
所以:
Always
specify the specific version you are using. Always
指定您正在使用的特定版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.