Skip to content
Advertisement

Django Web App running on local Debian 10 but failing on Azure

I can run my web app on my local machine – no errors. But when porting the directory strcture to Azure, I get the ModuleNotFoundError: No module named 'django'.

Here is what I did:

  • My app is publicly available on GitHub. The app runs in a virtual environment (called deploydjango). That is reflected in the tree structure of the repo.
  • I ensured that Python version was correct (3.8 as on my local machine).
  • I posted the code to Azure (using the Azure extension of Visual Studio Code).
  • When browsing to the web app URL, I get the error message:
:( Application Error
If you are the application administrator, you can access the diagnostic resources.
  • That takes me to Diagnose and solve problems on Azure page for the Web App Service. Here I find Availability and Performance.
    • Herein the tab “Web App Dow” is found.
      • Under Application Logs I am advised, that: Application logs from instance: lw0sdlwk00016P contain an error or a warning
      • Clicking More info, I get a log telling me:
2021-02-18T12:02:07.203140817Z [2021-02-18 12:02:07 +0000] [37] [ERROR] Exception in worker process
2021-02-18T12:02:07.203175518Z Traceback (most recent call last):
2021-02-18T12:02:07.203181819Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-02-18T12:02:07.203186419Z     worker.init_process()
2021-02-18T12:02:07.203190419Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2021-02-18T12:02:07.203285623Z     self.load_wsgi()
2021-02-18T12:02:07.203293724Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2021-02-18T12:02:07.203297724Z     self.wsgi = self.app.wsgi()
2021-02-18T12:02:07.203301124Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-02-18T12:02:07.203304824Z     self.callable = self.load()
2021-02-18T12:02:07.203308324Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2021-02-18T12:02:07.203312024Z     return self.load_wsgiapp()
2021-02-18T12:02:07.203315425Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2021-02-18T12:02:07.203321625Z     return util.import_app(self.app_uri)
2021-02-18T12:02:07.203325225Z   File "/opt/python/3.8.6/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2021-02-18T12:02:07.203328925Z     mod = importlib.import_module(module)
2021-02-18T12:02:07.203332425Z   File "/opt/python/3.8.6/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-02-18T12:02:07.203336226Z     return _bootstrap._gcd_import(name[level:], package, level)
2021-02-18T12:02:07.203349826Z   File "", line 1014, in _gcd_import
2021-02-18T12:02:07.203355026Z   File "", line 991, in _find_and_load
2021-02-18T12:02:07.203358827Z   File "", line 975, in _find_and_load_unlocked
2021-02-18T12:02:07.203362427Z   File "", line 671, in _load_unlocked
2021-02-18T12:02:07.203366027Z   File "", line 783, in exec_module
2021-02-18T12:02:07.203369727Z   File "", line 219, in _call_with_frames_removed
2021-02-18T12:02:07.203373527Z   File "/home/site/wwwroot/box_whiskers_demo/wsgi.py", line 12, in 
2021-02-18T12:02:07.203377427Z     from django.core.wsgi import get_wsgi_application
2021-02-18T12:02:07.203381027Z ModuleNotFoundError: No module named 'django'
2021-02-18T12:02:07.204377772Z [2021-02-18 12:02:07 +0000] [37] [INFO] Worker exiting (pid: 37)
2021-02-18T12:02:07.305791277Z [2021-02-18 12:02:07 +0000] [35] [INFO] Shutting down: Master
2021-02-18T12:02:07.312126259Z [2021-02-18 12:02:07 +0000] [35] [INFO] Reason: Worker failed to boot.

Advertisement

Answer

2021-02-18T12:02:07.203377427Z from django.core.wsgi import get_wsgi_application 2021-02-18T12:02:07.203381027Z ModuleNotFoundError: No module named ‘django’

above two lines says Django is not installed

If it is installed then check the below documentation:

https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#customize-startup-command

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement