简体   繁体   English

How to upload pandas, sqlalchemy package in lambda to avoid error "Unable to import module 'lambda_function': No module named 'importlib_metadata'"?

[英]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.

相关问题 AWS Lambda 错误消息“无法导入模块'lambda_function':没有名为'lambda_function'的模块”, - AWS Lambda error message “Unable to import module 'lambda_function': No module named 'lambda_function'”, 无法导入模块“ lambda_function”:没有名为“ error”的模块 - Unable to import module 'lambda_function': No module named 'error' Lambda Python 依赖包错误 Runtime.ImportModuleError:无法导入模块“lambda_function”:没有名为“surveys”的模块 - Lambda Python Dependency Package ERROR Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'surveys' 无法导入模块“lambda_function”:没有名为 xlrd 的模块 - Unable to import module 'lambda_function': No module named xlrd 无法导入模块“ lambda_function”:没有名为“ mysql”的模块 - Unable to import module 'lambda_function': No module named 'mysql' 无法导入模块“lambda_function”:没有名为 * 的模块 - Unable to import module 'lambda_function': No module named * 无法导入模块“lambda_function”:没有名为“pymongo”的模块 - Unable to import module 'lambda_function': No module named 'pymongo' 无法导入模块'lambda_function':没有名为'stomp'的模块 - Unable to import module 'lambda_function': No module named 'stomp' 在AWS Lambda中收到错误“无法导入模块'lambda_function':没有名为Flask的模块”的错误 - Getting the error “Unable to import module 'lambda_function': No module named Flask” in AWS Lambda AWS SAM Local和docker-lambda:继续无法导入模块'lambda_function':没有名为'lambda_function'的模块 - AWS SAM Local and docker-lambda: keep getting Unable to import module 'lambda_function': No module named 'lambda_function'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM