AWS Lambda with Zappa fails on "import module 'handler': No module named 'werkzeug' "

Viewed 1313

After deploying my python application with Zappa and visiting the aws link, I can see the following error:

enter image description here

When I checked the logs, I found the source of the error:

enter image description here

I then decided to pip install -r requirements.txt to ensure that it's installed inside my virtual environment (which it is):

Requirement already satisfied: Werkzeug==0.12 in ./flaskapi/lib/python3.6/site-packages (from -r requirements.txt (line 41))

Something is going wrong when it's uploaded to AWS. I'm not sure if this is the core issue, but I did notice the package name in the logs is different than the one inside requirements.txt file. The package name in the logs doesn't start with a capitalized 'W', while the package name in the requirements.txt does. Other than that, I'm not sure what I'm doing wrong.

Any and all help is appreciated

1 Answers

I solved this issue by upgrading to python 3.7 . I would recommend starting a new virtualenv, configured to use python 3.7 .

if you do not have python3.7 on your system, you will need to install it. This site is the one I used. Works on AWS cloud9 too.

installing python 3.7

virtualenv env -p python3.7 source ./env/bin/activate python --version output should be "Python 3.7.X"

then continue setting up your app like normal.

Related