Unable to import module 'main': No module named 'main'

0

I had a lambda function linked to API Gateway. All was working very fine. Then, I've updated a file who was in the zip file of the lambda function. I've rebuilded my zip file and upload it. And now I got the error: [ERROR] Runtime.ImportModuleError: Unable to import module 'main': No module named 'main' Traceback (most recent call last):

But I didn't change anything exept a code line inside a python which have no link with that error. I already checked the filename (main.py) and function name (lambda_handler) => main.lambda_handler, chmod, ... I have no clue. It's been hours that I can move on. I need help

3 Respostas
0
Resposta aceita

In some cases the error is related to a bad configuration in the value of handler. The handler value in the lambda configuration must have the value of the file.method. If your file is called _main.py and your method is called handler then you should set the value of the lambda handler to the following value "_main.handler"

respondido há um ano
profile picture
ESPECIALISTA
avaliado há 2 meses
  • Yes. That is exactly what I have. My file is called main.py and my function is called lambda_handler. In AWS, my function handler is main.lambda_handler

0

Did you zip it the same way as the procedure here?
https://repost.aws/knowledge-center/lambda-import-module-error-python

profile picture
ESPECIALISTA
respondido há um ano
0

It's working now. I've rebuilt my project from scratch but I still don't know why it didn't worked earlier

respondido há um ano

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas