求教如何解决ModuleNotFoundError: No module named 'djangoproject'
在app phones的目录下歇了 checkStatus.py 代码如下:
from django.conf import settingsimport os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoproject.settings")
print(settings.DATABASES)
当我运行 :python checkStatus.py ,报错了:
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 961, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'djangoproject'
但是我把这个脚本放到项目的根目录是可以正常运行的。我的代码结构如下:
├── phones│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── checkStatus.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── manage.py
├── readme.md
├── requirement.txt
└── djangoproject
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
├── views.py
└── wsgi.py
以上是 求教如何解决ModuleNotFoundError: No module named 'djangoproject' 的全部内容, 来源链接: utcz.com/p/938080.html