AWS Lambda层 [英] AWS Lambda Layer

查看:64
本文介绍了AWS Lambda层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将熊猫库导入到我的aws lambda层.但是给出一个错误消息说无法导入lambda.function:没有模块名称numpy.

I am trying to import pandas library to my aws lambda layer. But is gives an error saying to cannot import lambda.function: no module names numpy.

能不能解释一下熊猫和aws的问题.当我尝试使用SAM在pycharm上本地运行时,会引发相同的错误.

Can some explain what is the problem with pandas and aws. when I try to locally run it on pycharm using SAM it throws the same error.

推荐答案

如果您使用的是 AWS Lambda图层,您需要验证目录结构是否在图层所需的结构上:

If you are using AWS Lambda Layers you need to validate if your directory structure is on the needed structure for a layer:

例如,对于 pillow python模块,您需要以下结构:

For example for the pillow python module you need the following structure:

aws-lambda-layer.zip
│ python
│ python/PIL
└ python/Pillow-5.3.0.dist-info

因此,要创建具有正确结构的层zip文件,我们可以在项目的根目录上使用以下命令:

So to create a layer zip file with the correct structure we can use the following command on the root of our project:

mkdir -p python && cp -r <lib_name> python/ && zip -r aws-lambda-layer.zip python

这篇关于AWS Lambda层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆