简体   繁体   English

用于 Python 函数的 AWS Lambda 层导入

[英]AWS Lambda Layer import for Python function

I need to import the pysftp library for my python3.6 lambda function.我需要为我的python3.6 lambda 函数导入pysftp库。

I created the folder structure required, pip installed the library into the correct folder and zipped it.我创建了所需的文件夹结构,pip 将库安装到正确的文件夹中并进行了压缩。 As far as I know, this should work, or did i miss smth.据我所知,这应该有效,还是我错过了。 Btw I created the layer.zip in an aws Linux ec2 and uploaded it from there.顺便说一句,我在 aws Linux ec2 中创建了 layer.zip 并从那里上传了它。

But the lambda function just cant import the library.但是 lambda 函数无法导入库。 The Error message is:错误信息是:

{
  "errorMessage": "Unable to import module 'lambda_function'"
}

I found the solution.我找到了解决方案。 After setting everything up fresh I noticed I installed the libraries with pip instead of pip3.将所有内容重新设置后,我注意到我使用 pip 而不是 pip3 安装了库。 Just a minor misstype.只是一个小错误。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM