# \[ERROR\] ModuleNotFoundError: No module named 'werkzeug.\_compat'

**URL:** <https://forum.serverless.com/t/error-modulenotfounderror-no-module-named-werkzeug-compat/15687>\
**Category:** Serverless Framework\
**Tags:** lambda\
**Created:** [August 5, 2021, 12:30pm UTC](https://forum.serverless.com/t/error-modulenotfounderror-no-module-named-werkzeug-compat/15687 "2021-08-05T12:30:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![magomedov](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@magomedov](https://forum.serverless.com/u/magomedov)\
**Post date:** [August 5, 2021, 12:30pm UTC](https://forum.serverless.com/t/error-modulenotfounderror-no-module-named-werkzeug-compat/15687/1 "2021-08-05T12:30:54Z")

</div>

Hi team,

I have create a sample Flask API app and deployed it using aws keys.  
I did this following instructions on this page:  
[https://app.serverless.com/?package=aws-python-flask-api](https://app.serverless.com/?package=aws-python-flask-api)

Deployed it from the command-line on my machine - but now when I try accessing the published endpoints I am getting:

{“message”: “Internal server error”}

I went into the CloudWatch for the app see the following error:

```auto
[ERROR] ModuleNotFoundError: No module named 'werkzeug._compat'
Traceback (most recent call last):
  File "/var/task/serverless_sdk/ __init__.py", line 144, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_api.py", line 25, in error_handler
    raise e
  File "/var/task/s_api.py", line 20, in <module>
    user_handler = serverless_sdk.get_user_handler('wsgi_handler.handler')
  File "/var/task/serverless_sdk/ __init__.py", line 56, in get_user_handler
    user_module = import_module(user_module_name)
  File "/var/lang/lib/python3.8/importlib/ __init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/wsgi_handler.py", line 22, in <module>
    import serverless_wsgi
  File "/var/task/serverless_wsgi.py", line 18, in <module>
    from werkzeug._compat import BytesIO, string_types, to_bytes, wsgi_encoding_dance

```

I read the documentation and seem that the package werkzeug may be missing - but it is required only when running serverless on a machine - but should work without it when deployed serverless.

Any ideas?

I did include werkzeug into requirements.txt - but still doesn’t help - I get the same error.

Any ideas?

Thanks!

---

<div class="post-metadata">

**Author:** ![garethmcc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/garethmcc/32/2276_2.png) [@garethmcc](https://forum.serverless.com/u/garethmcc)\
**Post date:** [August 5, 2021, 12:51pm UTC](https://forum.serverless.com/t/error-modulenotfounderror-no-module-named-werkzeug-compat/15687/2 "2021-08-05T12:51:41Z")

</div>

This is an issue currently with the serverless-wsgi plugin used to deploy Serverless applications that has since been resolved by the plugin author.You can find more information here: [Werkzeug updated. Getting errors · Issue #179 · logandk/serverless-wsgi · GitHub](https://github.com/logandk/serverless-wsgi/issues/179)

---

<div class="post-metadata">

**Author:** ![magomedov](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@magomedov](https://forum.serverless.com/u/magomedov)\
**Post date:** [August 5, 2021, 1:11pm UTC](https://forum.serverless.com/t/error-modulenotfounderror-no-module-named-werkzeug-compat/15687/3 "2021-08-05T13:11:15Z")

</div>

Thanks for the reply! Looks like this was driven by python 2 compatibility issues. Btw since I posted my question I managed to resolve it by changing Flask version in the requirements.txt to  
Flask==1.1.4  
and removing werkzeug from it altogether.

Thanks for your reply anyway!

---

<div class="post-metadata">

**Author:** ![corinnaucdjv](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@corinnaucdjv](https://forum.serverless.com/u/corinnaucdjv)\
**Post date:** [May 17, 2022, 7:00am UTC](https://forum.serverless.com/t/error-modulenotfounderror-no-module-named-werkzeug-compat/15687/4 "2022-05-17T07:00:15Z")

</div>

Hello, I’m just new to serverless and I just managed to get Python installed on Microsoft code.  
Now I’ve connected my pyboard 1.1 and try to run a default program.  
The first error I hit is: ModuleNotFoundError: No module named ‘pyb’

I hope someone can help solve this? Thanks.
