Lambda with layers: Runtime.ImportModuleError: Unable to import module


The zip file structure looks as expected by lambda so not sure why I am getting this error. My lambda function is and it directly at the root of the zip/folder structure - folder-structure Runtime config: Runtime Python 3.12 HandlerInfo main-lambda.lambda_handler ArchitectureInfo x86_64

Structure:- nupeacock-main-backend | |

asked 19 days ago131 views
2 Answers

Firstly, it appears that your lambda function code is nested inside the zip file/folder - which seems to be your library ( Try moving your Lambda function code up to the root folder (nupeacock-main-backend) and run test again. It could be that your Lambda function code couldn't find the path to your library.

Secondly, you mentioned "layers", are your libraries deployed as Lambda Layer? Or you intend to just refer to your libraries as path-relative to your Lambda function as you did above?

answered 18 days ago
  • Yes, already tried it and it works now.



Python 3.12 is based on an Amazon Linux 2023 Amazon Machine Image (AMI). So, create the layer on an Amazon Linux 2023 OS.

Follow this article to troubleshoot this error ,

profile picture
answered 19 days ago
  • thank you for your response but the issue is with calling the main lambda handler function itself (which is correctly located in the root folder of zip) and not with dependencies so not sure I agree with your response.

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