AWS Lambda-无法导入模块 [英] AWS Lambda - Unable to import module

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

问题描述

我正在尝试从S3上传.zip文件以在lambda函数上运行.这样做时,出现以下错误:

I am attempting to upload a .zip file from S3 to run on a lambda function. When doing so, I get the following error:

START RequestId: 578fc1bb-9c82-11e7-b2c9-91da0a832381 Version: $LATEST
Unable to import module 'create_heatmap': No module named create_heatmap

END RequestId: 578fc1bb-9c82-11e7-b2c9-91da0a832381
REPORT RequestId: 578fc1bb-9c82-11e7-b2c9-91da0a832381  Duration: 0.31 ms   Billed Duration: 100 ms     Memory Size: 128 MB Max Memory Used: 18 MB

上面是我压缩并上传到lambda的文件夹.您可以看到在此顶级目录中有一个create_heatmap.py文件.

Above is the folder which I zipped up and uploaded to lambda. You can see there is a create_heatmap.py file in this top level directory.

我布置的处理程序配置如下所示:

The handler configuration I have laid out can be seen below:

最后,这是create_heatmap.py中的lambda_handler函数.

And last, here is the lambda_handler function in create_heatmap.py.

def lambda_handler(event,context):
    hm = Heatmap(course_name=event.get('course_name',None),horizontal=event.get('horizontal',[]),num_topics=event.get('num_topics',10))
    hm.run()

我无法弄清楚为什么目前无法正常工作.任何建议将不胜感激.

I cannot figure out why this is not working at the moment. Any suggestions would be greatly appreciated.

推荐答案

请确保存档中文件的权限至少为444,这使我暂时感到困惑.如果这不起作用,请在此帖子.

Make sure the permissions on the files in the archive are at least 444 -- this tripped me up for awhile. If that doesn't work, check out the other answers on this post.

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

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