简体   繁体   English

AWS Lambda Opencv(“无法导入模块‘lambda_function’:libgthread-2.0.so.0:无法打开共享对象文件:没有这样的文件或目录”)

[英]AWS Lambda Opencv ("Unable to import module 'lambda_function': libgthread-2.0.so.0: cannot open shared object file: No such file or directory")

Trying to make an import of cv2 in aws lambda.尝试在 aws lambda 中导入 cv2。 Tried to install it with a layer with an arn from this link: https://github.com/keithrozario/Klayers/blob/master/deployments/python3.8/arns/eu-west-3.csv尝试通过此链接使用带有 arn 的层安装它: https ://github.com/keithrozario/Klayers/blob/master/deployments/python3.8/arns/eu-west-3.csv

But i get an error and have trouble to solve it: "Unable to import module 'lambda_function': libgthread-2.0.so.0: cannot open shared object file: No such file or directory"但是我得到一个错误并且很难解决它:“无法导入模块'lambda_function':libgthread-2.0.so.0:无法打开共享对象文件:没有这样的文件或目录”

My lambda works with python 3.8 also.我的 lambda 也适用于 python 3.8。 I also tried python 3.6 and 3.7.我还尝试了 python 3.6 和 3.7。

Does anybody have a fonctionnal Klayer arn for opencv?有人有用于 opencv 的功能性 Klayer arn 吗? Or a usefull tutorial to make it.或者一个有用的教程来制作它。

import json
import cv2 


def lambda_handler(event, context):
    # TODO implement
    
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Was searching for an answer and found the solution here: https://github.com/keithrozario/Klayers/issues/115正在寻找答案并在这里找到解决方案: https : //github.com/keithrozario/Klayers/issues/115

It requires both the opencv module and libgthread-2.0.so.0 to work.它需要 opencv 模块和 libgthread-2.0.so.0 才能工作。

Go to https://github.com/keithrozario/Klayers again and look for the "libgthread-so" package.再次访问https://github.com/keithrozario/Klayers并查找“libgthread-so”包。 Add the libgthread-so package as a new layer and it should work.添加 libgthread-so 包作为一个新层,它应该可以工作。

I was also on the same error but as @jen said that you must have libgthread-so to make this work我也遇到了同样的错误,但正如@jen 所说,您必须拥有 libgthread-so 才能完成这项工作

Add this to your lambda layer将此添加到您的 lambda 层

arn:aws:lambda:ap-south-1:770693421928:layer:Klayers-python38-libgthread-so:1

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 aws lambda 无法导入模块“lambda_function”:没有名为“requests”的模块 - aws lambda Unable to import module 'lambda_function': No module named 'requests' 无法导入模块“lambda_function”:没有名为“psycopg2._psycopg aws lambda 函数”的模块 - Unable to import module 'lambda_function': No module named 'psycopg2._psycopg aws lambda function Lambda 函数 - 文件结构 - Lambda Function - File Structre 继续构建失败,无法使用 SAM CLI 为 lambda function 保存 main.go 文件的导入 - Keep getting build fail and unable to save import for main.go file for lambda function using SAM CLI 无法在 AWS Lambda 上使用请求模块 - Cannot use Requests-Module on AWS Lambda AWS Lambda 函数抛出 ClassNotFoundException - LambdaHandler。 当前类路径:file:/var/task/ - AWS Lambda function throws ClassNotFoundException - LambdaHandler. Current classpath: file:/var/task/ 如何使用 AWS Lambda 函数从 S3 解码 a.gz 文件? - How can I decode a .gz file from S3 using an AWS Lambda function? AWS Lambda nodejs 函数中的事件对象为空 - Event Object is empty in AWS Lambda nodejs function 如何使用 ctypes.util.find_library 导入 AWS lambda(python)中的 so 库? - How to use ctypes.util.find_library to import .so libraries in AWS lambda (python)? Lex 无法访问 Lambda 函数 - Lex is unable to access the Lambda function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM