Common Zappa Newbie Issue:
“Unable to import module ‘handler’: attempted relative import with no known parent package”
If you have encountered this error in Zappa, the chances are you have not put together the right virtual environment and deployed your dependencies for the zappa lambda function.
Underneath the covers, zappa is creating a ‘handler’ module which contains all of the goodness to bootstrap your Flask stuff inside of a lambda function. If somehow the files that make up zappa don’t make it to your deployment you will see this error. If you miss some other dependencies, you will see a similar error.
To resolve this issue do the following:
pip freeze > requirements.txt
Ensure that the dependencies you’re expecting are showing up here. If they aren’t, you may have installed them into the global python environment or some other virtual environment by mistake.
Make sure you’re in your zappa project’s virtual environment and install the dependencies again and then perform an update:
zappa update dev
You should then be able to tail the logs for your lambda function and see happiness after this.