我需要帮助解决AWS Lambda中的Runtime.ImportModuleError

2024-06-16 14:14:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我是AWS Lambda的新手,我正在尝试在用Python编写的Lambda函数的测试场景中运行一个简单的print('hello')语句。但是,我不断得到Runtime.ImportModuleError。这是我的密码:

import boto3

def handler(event, context):
    s3 = boto3.client('s3')
    csvfile = s3.get_object(Bucket='mybucket', Key='fname.csv')
    print('hello')

以下是我的函数名:

enter image description here

以下是我的运行时设置:

enter image description here

我的测试事件配置为:

{
  "key1": "value1",
  "key2": "value2",
  "key3": "value3"
}

但是,当我点击“测试”按钮时,我收到以下错误消息:

Response
{
  "errorMessage": "Unable to import module 'dts_scrape': No module named 'dts_scrape'",
  "errorType": "Runtime.ImportModuleError"
}

有人知道这里发生了什么吗


Tags: lambda函数importawshellos3场景boto3