添加app时的Django ModuleNotFoundError

时间:2018-03-04 05:14:00

标签: python django

我使用Visual Studio和Python工具开发我的Django项目。我通过IDE创建了一个应用程序。但是在将应用程序添加到我的settings.py中的INSTALLED_APPS后,它总是给我ModuleNotFound错误

这是目录结构。

enter image description here

这就是我添加应用

的方式
INSTALLED_APPS = [
    # Add your apps here to enable them
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'kleis',
]

堆栈跟踪

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000228FCA30A60>
Traceback (most recent call last):
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\core\management\commands\runserver.py", line 113, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\core\management\__init__.py", line 327, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\apps\registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "C:\Users\Sam\Documents\Exceptions\Projects\Kleis\Backend Django\Server\Server\env\lib\site-packages\django\apps\config.py", line 90, in create
    module = import_module(entry)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\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 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'kleis'

0 个答案:

没有答案