howtographql / howtographql

The Fullstack Tutorial for GraphQL

Home Page:https://www.howtographql.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModuleNotFoundError: No module named 'djangoproject'

chunxiao365 opened this issue · comments

I write checkStatus.py in app phones,code following:
`from django.conf import settings
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoproject.settings")
print(settings.DATABASES)`
when I run :python checkStatus.py , it responses error like:
########
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'

########
my project structure as follows:

├── 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

thank you very much

I have solved this issue:
1.First set your PYTHONPATH
export PYTHONPATH=/Users/xiaohu/PycharmProjects/djangoproject
2 .then set DJANGO_SETTINGS_MODULE
export DJANGO_SETTINGS_MODULE=djangoproject.settings