Error - AWS Lamda

0

How could I resolve this error on AWS lamda?

  "errorMessage": "Unable to import module 'lambda_function': No module named 'requests'",
   "errorType": "Runtime.ImportModuleError",
   "requestId": "58b6910d-444d-4e69-8a6b-21d606284df4",
   "stackTrace": []

I tried to insert the layer below but it did not work. arn:aws:lambda:ap-northeast-1:770693421928:layer:Klayers-p39-requests:19

Best regards,

asked a year ago814 views
2 Answers
0
Accepted Answer

Hello.

"arn:aws:lambda:ap-northeast-1:770693421928:layer:Klayers-p39-requests:19" is compatible with Python3.9, so I think it may not work depending on the Python version.
So, why not try creating your own layer using the steps in the document below?
https://docs.aws.amazon.com/lambda/latest/dg/python-layers.html

profile picture
EXPERT
answered a year ago
EXPERT
reviewed a year ago
0

To resolve the error "Unable to import module 'lambda_function': No module named 'requests'" in AWS Lambda, you can use a Lambda layer to include the necessary Python packages. Note that Lambda only supports Linux system Python packages.

  1. First, you have to install the python packages on any Linux machine either local or use AWS EC2 instance.
  2. Then zip the python package.
  3. Finally, upload the zip file into lambda layer and add the layer into lambda function.
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions