You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get the following error when using serverless-wsgi on Azure.
Exception while executing function: Functions.app Result: Failure
Exception: ModuleNotFoundError: No module named 'serverless_wsgi'
Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 238, in _handle__function_load_request
func = loader.load_function(
File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 66, in load_function
mod = importlib.import_module(fullmodname)
File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/site/wwwroot/wsgi_handler.py", line 22, in
import serverless_wsgi
When reading up on the python developer reference here, you can see that referring to a local module only works with explicit relative or absolute paths, but not implicit relative.
A fix might be to change line 22 of wsgi_handler.py to from . import serverless_wsgi
I'm using serverless_wsgi version 1.7.5.
Note that running serverless locally with 'sls wsgi serve' works like a charm :)
The text was updated successfully, but these errors were encountered:
Hi @MattiasDC,
Yeah, I've not tested on Azure personally - on AWS, the package root is PYTHONPATH, so it's not importing from a relative path and there's no issue.
Did you test that from . import serverless_wsgi works on Azure? And I assume you had to add __init__.py to the package root as well?
In that case, I suppose we catch the exception when importing from PYTHONPATH and fall back to the relative import. Another option would be to check whether PYTHONPATH is where wsgi_handler.py is and whether there's an __init__.py (assuming it's required), and import accordingly. I don't think we should add __init__.py automatically, but we should probably emit a warning if it's required on Azure and is not present in the project.
I get the following error when using serverless-wsgi on Azure.
When reading up on the python developer reference here, you can see that referring to a local module only works with explicit relative or absolute paths, but not implicit relative.
A fix might be to change line 22 of wsgi_handler.py to
from . import serverless_wsgi
I'm using serverless_wsgi version 1.7.5.
Note that running serverless locally with 'sls wsgi serve' works like a charm :)
The text was updated successfully, but these errors were encountered: