在PyCharm中运行程序时django.core.exceptions.ImproperlyConfigured错误

时间:2018-08-01 22:26:24

标签: python django pycharm wsgi django-wsgi

我的同伴能够在Mac上运行我的代码。我无法克服此错误。在Windows中使用virtualenv在PyCharm中运行应用程序时遇到了它。

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x04E22150> Traceback (most recent call last):   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\utils\module_loading.py", line 13, in import_string
    module_path, class_name = dotted_path.rsplit('.', 1) ValueError: not enough values to unpack (expected 2, got 1)

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

Traceback (most recent call last):   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\core\servers\basehttp.py", line 44, in get_internal_wsgi_application
    return import_string(app_path)   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\utils\module_loading.py", line 15, in import_string
    raise ImportError("%s doesn't look like a module path" % dotted_path) from err ImportError: application doesn't look like a module path

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

Traceback (most recent call last):   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\core\management\commands\runserver.py", line 137, in inner_run
    handler = self.get_handler(*args, **options)   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler
    handler = super().get_handler(*args, **options)   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\core\management\commands\runserver.py", line 64, in get_handler
    return get_internal_wsgi_application()   File "C:\Users\Tacfa\Google Drive\Code\CS33A\project3_env\lib\site-packages\django\core\servers\basehttp.py", line 49, in get_internal_wsgi_application
    ) from err django.core.exceptions.ImproperlyConfigured: WSGI application 'application' could not be loaded; Error importing module.

我的wsgi.py如下:

import os from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinocchios.settings")

os.path.realpath(os.path.dirname(__file__))

application = get_wsgi_application()

settings.py:

WSGI_APPLICATION = 'wsgi.application'

0 个答案:

没有答案