简体   繁体   中英

AWS Lambda error message “Unable to import module 'lambda_function': No module named 'lambda_function'”,

I am trying to upload a zip file to AWS lambda but keep getting the error "Unable to import module 'lambda_function': No module named 'lambda_function'"

I've started very basic by creating a zip file named "lambda_function.zip" with one file inside "lambda_function.py". At a later stage I will need to include packages in the zip file, but for now it's a very simple function named lambda_handler only using json.

Once uploaded this is the file structure and the error message received after testing: code and error message screenshot

If I move lamda_function.py into the root folder "RWS-POC" then it works, but later on when I need to upload a larger zip file this won't be an option as editing via the interface is disabled.

I can also confirm that the handler is set to lambda_function.lambda_handler and the python file is named "lambda_function" and the function named "lambda_handler" lambda_function.lambda_handler settings screenshot

I'm sure I'm doing something very basic wrong, so any help would be very much appreciated.

Thanks!

Your lambda_function.py is inside folder called lambda_function . Just move your lambda_function to RWS-POC , or modify handler into:

lambda_function/lambda_function.lambda_handler

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM