python-3.x django.core.exceptions. ImproblyConfigured:WSGI应用程序“wsgi.application”无法加载;导入模块时出错

ckocjqey  于 2023-11-20  发布在  Python
关注(0)|答案(3)|浏览(185)

我曾经检查过这个问题的每一个答案,但没有任何帮助。这里有一个完整的追溯:

Traceback (most recent call last):
File "/home/deadpoll/env/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 44, in get_internal_wsgi_application
return import_string(app_path)
File "/home/deadpoll/env/lib/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/home/deadpoll/env/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'wsgi'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/deadpoll/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/deadpoll/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 140, in inner_run
handler = self.get_handler(*args, **options)
File "/home/deadpoll/env/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "/home/deadpoll/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 65, in get_handler
return get_internal_wsgi_application()
File "/home/deadpoll/env/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
) from err
django.core.exceptions.ImproperlyConfigured: WSGI application 'wsgi.application' could not be loaded; Error importing module.

字符串
请在github上查看我的完整项目:
https://github.com/nabirhossain/MyBlog

ru9i0ody

ru9i0ody1#

请确保将您的应用程序添加到项目的settings.py文件中,并位于XNUMERED_APPS下。
当我错误地将应用程序添加到MIDDLEWARE部分时,我也面临着同样的错误。

lsmd5eda

lsmd5eda2#

经过长时间的努力,让事情工作后,我能够成功地运行服务器后,从WSGI到asgi配置的变化,这不是一件坏事,因为asgi是WSGI的继任者打开settings.py删除WSGI配置或注解隐藏它像我一样

# WSGI_APPLICATION = 'DjangoBlog.wsgi.application' 

ASGI_APPLICATION = 'DjangoBlog.asgi.application'`

字符串
然后创建名为asgi.py的文件并将此代码粘贴到其中

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoBlog.settings')

application = get_asgi_application()


DjangoBlog是我的项目的名称,将其更改为适合您的项目

svmlkihl

svmlkihl3#

是的,当你在中间件设置中导入一些不存在的东西时,错误通常会出现。错误并不总是很清楚,但请尝试检查导入的模块。

相关问题