Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda "Unable to import module 'handler': No module named handler" [closed]

AWS Lambda 'python2.7' can not find my module handler.

START RequestId: c6f97261-ba61-11e7-aeaf-bfb6aa28f7bb Version: $LATEST
Unable to import module 'handler': No module named handler

END RequestId: c6f97261-ba61-11e7-aeaf-bfb6aa28f7bb
REPORT RequestId: c6f97261-ba61-11e7-aeaf-bfb6aa28f7bb  Duration: 0.33 ms   Billed Duration: 100 ms Memory Size: 1024 MB    Max Memory Used: 19 M

handler.py

def handler(event, context):
    return {'status': 'success'}

Folder structure:

  • handler.py

Written on Windows 10, Deployed using serverless on Ubuntu VM from shared folder with host system. (virtualbox)

like image 263
M.Vanderlee Avatar asked Oct 21 '25 04:10

M.Vanderlee


1 Answers

Turns out this is a permission issue. Running chmod 644 handler.py then redeploying fixed the issue.

In my case this was caused by deploying from a shared folder on my Ubuntu VM (Win10 host). Shared folders have rwxrwx--- permissions, which is not enough for AWS Lambda. I needed to copy the folder and run chmod in the copied folder, then deploy from there.

like image 122
M.Vanderlee Avatar answered Oct 23 '25 20:10

M.Vanderlee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!