Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to import module 'handler': No module named 'werkzeug'

I suddenly started getting this error on a Django + AWS lambda setup with zappa. I'm using ubuntu 18.04 image on bitbucket pipelines to trigger the deployment.

Unable to import module 'handler': No module named 'werkzeug'

It was working fine for python3.6 on zappa==0.42.2 until the last deployment in 25-July-2019. I thought it was due to some code changes on the app that's causing it (even though the code changes are not related to pip modules - just some updates on the application's codebase) but even reverting to previous deployments are throwing this error now.

My zappa config has a slim_handler: true

{
    "staging": {
        "project_name": "myapp",
        "slim_handler": true,
        "runtime": "python3.6",
        "log_level": "WARNING",
        "timeout_seconds": 300
    }
}

I have tried some suggested solutions in Zappa's GitHub issues but without success.

  • https://github.com/Miserlou/Zappa/issues/64
  • https://github.com/Miserlou/Zappa/issues/1549

I've also tried some SO solutions from questions related to import issues in zappa and haven't been successful. I would highly appreciate any pointers for debugging or workarounds for this zappa issue in AWS lambda with python3.6.

like image 649
sa77 Avatar asked Jul 27 '19 03:07

sa77


1 Answers

For people who are facing similar issue

I fixed it by install zappa in the venv itself.

So, follow the steps (assuming you have venv in env folder locally)

$ source ./env/bin/activate
$ pip install zappa
$ zappa deploy or zappa update
like image 79
virtuvious Avatar answered Nov 10 '22 22:11

virtuvious