本地 Debian 10 上的 Django Web App 运行 但在 Azure 上失败

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

我可以 运行 我的网络应用程序在我的本地机器上 - 没有错误。 但是当将目录结构移植到 Azure 时,我得到 ModuleNotFoundError: No module named 'django'.

这是我所做的:

:( Application Error
If you are the application administrator, you can access the diagnostic resources.
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.

2021-02-18T12:02:07.203377427Z 来自 django.core.wsgi 导入 get_wsgi_application 2021-02-18T12:02:07.203381027Z ModuleNotFoundError:没有名为 'django'

的模块

上面两行表示 Django 没有安装

如果已安装,请检查以下文档:

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