serverless-python-requirements
serverless-python-requirements copied to clipboard
Getting error with deployed Serverless Flask app on AWS, [ERROR] Runtime.ImportModuleError: Unable to import module 'wsgi_handler': No module named 'werkzeug'
Hi I am facing error - [ERROR] Runtime.ImportModuleError: Unable to import module 'wsgi_handler': No module named 'werkzeug'
while deploying serverless application with python3.9.
serverless.yml
service: serverless-service # give the service name
plugins:
- serverless-python-requirements
- serverless-wsgi
- serverless-dotenv-plugin
custom:
wsgi:
app: test_wsgi.app # wsgi file
packRequirements: false
pythonRequirements:
dockerizePip: non-linux
provider:
name: aws
runtime: python3.9 # Specify the run time environement
stage: dev # For testing use dev
region: us-west-2 # region specify
lambdaHashingVersion: 20201221 # Optional, version of hashing algorithm that should be used by the framework
package:
individually: true
exclude:
- ./**
include:
- requirements.txt
functions:
app:
handler: wsgi_handler.handler # For api gateway we need to use
timeout: 30 # Default timeout
events: # If we have any other method type add below
- http: ANY /
- http: 'ANY {proxy+}'
requirements.txt
flask==2.1.0
flask-api==3.0.post1
flask-cors===3.0.9
flask-restful==0.3.9
python-dotenv~=0.20.0
#boto3~=1.16.18
#flask-restful
boto3~=1.16.18
requests~=2.28.1
PyJWT==1.7.1
pycryptodomex
werkzeug==2.0.1
can anyone please help in this?
try Werkzeug==2.0.1
I have the exact same issue. Downgrading does not help!
Also seeing this issue, anyone found a solution?
@victorstefan13 what version of Flask are you using? Some of them requires werkzeug
to be installed separately
Hey @pgrzesik I am using Flask version 2.2.3 but I also have Werkzeug as its own dependency version 2.2.3. I can see the package is in my requirements.txt
file which gets generated at the root of my project through poetry. I have also tried older versions, Flask v1.1.4 and Werkzeug v1.0.1 and I was getting the same issue so I am a bit stunned.
My solution.
Bug Report: Serverless Offline Missing WSGI Files
Title: sls offline fails to create required WSGI files
Severity: High
Environment:
- Serverless Framework version: 4
- OS: Linux
- Python version: 3.8
Description:
sls offline
doesn't create files, which are necessary for WSGI applications.
Steps to Reproduce:
- Run
sls deploy
- Run
sls offline
- Observe missing files
Expected: sls offline
creates required WSGI files
Actual: Files are not generated
Workaround:
Run sls wsgi install && sls offline