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:
JavaScript
x
3
1
:( Application Error
2
If you are the application administrator, you can access the diagnostic resources.
3
- 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:
- Under
- Herein the tab “Web App Dow” is found.
JavaScript
1
31
31
1
2021-02-18T12:02:07.203140817Z [2021-02-18 12:02:07 +0000] [37] [ERROR] Exception in worker process
2
2021-02-18T12:02:07.203175518Z Traceback (most recent call last):
3
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
4
2021-02-18T12:02:07.203186419Z worker.init_process()
5
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
6
2021-02-18T12:02:07.203285623Z self.load_wsgi()
7
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
8
2021-02-18T12:02:07.203297724Z self.wsgi = self.app.wsgi()
9
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
10
2021-02-18T12:02:07.203304824Z self.callable = self.load()
11
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
12
2021-02-18T12:02:07.203312024Z return self.load_wsgiapp()
13
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
14
2021-02-18T12:02:07.203321625Z return util.import_app(self.app_uri)
15
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
16
2021-02-18T12:02:07.203328925Z mod = importlib.import_module(module)
17
2021-02-18T12:02:07.203332425Z File "/opt/python/3.8.6/lib/python3.8/importlib/__init__.py", line 127, in import_module
18
2021-02-18T12:02:07.203336226Z return _bootstrap._gcd_import(name[level:], package, level)
19
2021-02-18T12:02:07.203349826Z File "", line 1014, in _gcd_import
20
2021-02-18T12:02:07.203355026Z File "", line 991, in _find_and_load
21
2021-02-18T12:02:07.203358827Z File "", line 975, in _find_and_load_unlocked
22
2021-02-18T12:02:07.203362427Z File "", line 671, in _load_unlocked
23
2021-02-18T12:02:07.203366027Z File "", line 783, in exec_module
24
2021-02-18T12:02:07.203369727Z File "", line 219, in _call_with_frames_removed
25
2021-02-18T12:02:07.203373527Z File "/home/site/wwwroot/box_whiskers_demo/wsgi.py", line 12, in
26
2021-02-18T12:02:07.203377427Z from django.core.wsgi import get_wsgi_application
27
2021-02-18T12:02:07.203381027Z ModuleNotFoundError: No module named 'django'
28
2021-02-18T12:02:07.204377772Z [2021-02-18 12:02:07 +0000] [37] [INFO] Worker exiting (pid: 37)
29
2021-02-18T12:02:07.305791277Z [2021-02-18 12:02:07 +0000] [35] [INFO] Shutting down: Master
30
2021-02-18T12:02:07.312126259Z [2021-02-18 12:02:07 +0000] [35] [INFO] Reason: Worker failed to boot.
31
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: