Django:没有名为“ project”的模块

时间:2019-08-04 06:01:37

标签: python django

我当时在个人笔记本电脑上从事Django项目。然后,我将该项目克隆到了我的笔记本电脑上,尝试运行任何命令,例如python manage.py runserver时,我遇到一个非常奇怪的错误:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/core/management/base.py", line 336, in run_from_argv
    connections.close_all()
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 219, in close_all
    for alias in self:
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 213, in __iter__
    return iter(self.databases)
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/db/utils.py", line 147, in databases
    self._databases = settings.DATABASES
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/jmetz/github/personal/golf-swings-api/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Users/jmetz/miniconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'project'

知道什么是问题吗?

1 个答案:

答案 0 :(得分:0)

将项目添加到settings.py文件中的INSTALLED_APPS

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            GeometryReader { gp in
                VStack(alignment: HorizontalAlignment.center) {
                    Text("Width: \(gp.size.width)")
                    Text("Height: \(gp.size.height)")
                }
            }
        }
    }
}