[英]How to upload pandas, sqlalchemy package in lambda to avoid error "Unable to import module 'lambda_function': No module named 'importlib_metadata'"?
I'm trying to upload a deployment package to my AWS lambda function following the article https://korniichuk.medium.com/lambda-with-pandas-fd81aa2ff25e . I'm trying to upload a deployment package to my AWS lambda function following the article https://korniichuk.medium.com/lambda-with-pandas-fd81aa2ff25e . My final zip file is as follows: https://drive.google.com/file/d/1NLjvf_-Ks50E8z53DJezHtx7-ZRmwwBM/view but when I run my lambda function I get the error
Unable to import module 'lambda_function': No module named 'importlib_metadata'
My final zip file is as follows: https://drive.google.com/file/d/1NLjvf_-Ks50E8z53DJezHtx7-ZRmwwBM/view but when I run my lambda function I get the error
Unable to import module 'lambda_function': No module named 'importlib_metadata'
My handler is named lambda_function.lambda_handler
which is the file name and the function to run.我的处理程序被命名为
lambda_function.lambda_handler
这是文件名和 function 运行。 I also tried uploading these zip files as layers excluding the lambda_function.py
and get:我还尝试将这些 zip 文件作为不包括
lambda_function.py
的层上传并获得: What am I doing wrong?
我究竟做错了什么?
EDIT: I tried using zip/lambda_function.lambda_handler
as my handler still getting Unable to import module 'zip/lambda_function': No module named 'zip/lambda_function'
编辑:我尝试使用
zip/lambda_function.lambda_handler
作为我的处理程序仍然Unable to import module 'zip/lambda_function': No module named 'zip/lambda_function'
There is a third party github repo with public layers, including pandas.有一个带有公共层的第三方 github repo ,包括 pandas。 You don't have to do anything to use, except adding the layer arn to your function.
除了将层 arn 添加到 function 之外,您无需执行任何操作。 The arn depends on your region , so you have to choose your region.
arn 取决于您所在的地区,因此您必须选择您所在的地区。 For example, for
us-east-1
the pandas layer for python 3.8 is:例如,对于
us-east-1
,python 3.8 的 pandas 层为:
arn:aws:lambda:us-east-1:770693421928:layer:Klayers-python38-pandas:31
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.