AWS Lambda import module error in python

后端 未结 21 1491
醉话见心
醉话见心 2020-12-07 19:56

I am creating a AWS Lambda python deployment package. I am using one external dependency requests . I installed the external dependency using the AWS documentation http://do

21条回答
  •  执笔经年
    2020-12-07 20:26

    I found Nithin's answer very helpful. Here is a specific walk-through:

    Look-up these values:

    1. The name of the lambda_handler function in your python script. The name used in the AWS examples is "lambda_handler" looking like "def lambda_handler(event, context)". In this case, the value is "lambda_handler"
    2. In the Lambda dashboard, find the name of the Handler in the "Handler" text-box in the "Configuration" section in the lambda dashboard for the function (shown in Nithin's screenshot). My default name was "lambda_function.lambda_handler".
    3. The name of your python script. Let's say it's "cool.py"

    With these values, you would need to rename the handler (shown in the screenshot) to "cool.lambda_handler". This is one way to get rid of the "Unable to import module 'lambda_function'" errorMessage. If you were to rename the handler in your python script to "sup" then you'd need to rename the handler in the lambda dashboard to "cool.sup"

提交回复
热议问题