gpt4 book ai didi

python - 导入模块时出错 - 配置不正确 : WSGI application

转载 作者:太空宇宙 更新时间:2023-11-03 14:19:24 24 4
gpt4 key购买 nike

我最初使用名为 auth 的应用程序创建了一个 Django 项目,但遇到了一些错误,并将其更改为 authentication。后来,当尝试 runserver 时,我发现由于错误而无法运行:

django.core.exceptions.ImproperlyConfigured: WSGI application 'coolwebsite.wsgi.application' could not be loaded; Error importing module: 'No module named 'django.contrib.authentication''

所以我在网上查了一下,结果发现我不应该用与 Django 的应用程序结构相同的名称来命名应用程序。我将 authentication 更改为 oauth,但仍然收到相同的错误:

django.core.exceptions.ImproperlyConfigured: WSGI application 'coolwebsite.wsgi.application' could not be loaded; Error importing module: 'No module named 'django.contrib.oauth''

我将应用程序名称更改为birds,但仍然会收到相同的错误。我不明白为什么我仍然收到此错误。

完整的错误是:

Traceback (most recent call last):
File "C:\python3.6.3\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\python3.6.3\lib\site-packages\django\core\management\commands\runserver.py", line 147, in inner_run
handler = self.get_handler(*args, **options)
File "C:\python3.6.3\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 28, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "C:\python3.6.3\lib\site-packages\django\core\management\commands\runserver.py", line 68, in get_handler
return get_internal_wsgi_application()
File "C:\python3.6.3\lib\site-packages\django\core\servers\basehttp.py", line 57, in get_internal_wsgi_application
sys.exc_info()[2])
File "C:\python3.6.3\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\python3.6.3\lib\site-packages\django\core\servers\basehttp.py", line 47, in get_internal_wsgi_application
return import_string(app_path)
File "C:\python3.6.3\lib\site-packages\django\utils\module_loading.py", line 20, in import_string
module = import_module(module_path)
File "C:\python3.6.3\lib\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 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\xxx\PycharmProjects\coolwebsite\coolwebsite\wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "C:\python3.6.3\lib\site-packages\django\core\wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "C:\python3.6.3\lib\site-packages\django\core\handlers\wsgi.py", line 151, in __init__
self.load_middleware()
File "C:\python3.6.3\lib\site-packages\django\core\handlers\base.py", line 80, in load_middleware
middleware = import_string(middleware_path)
File "C:\python3.6.3\lib\site-packages\django\utils\module_loading.py", line 20, in import_string
module = import_module(module_path)
File "C:\python3.6.3\lib\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 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
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
django.core.exceptions.ImproperlyConfigured: WSGI application 'coolwebsite.wsgi.application' could not be loaded; Error importing module: 'No module named 'django.contrib.oauth''

我安装的应用程序:

INSTALLED_APPS = [
###APPS###
'oauth.apps.OauthConfig',

'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
]

为什么我会收到此错误?

最佳答案

因为这些模块都不存在。该应用程序名为“django.contrib.auth”。

关于python - 导入模块时出错 - 配置不正确 : WSGI application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48038320/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com