Когда я запускаю проект Django на локальном сервере, он не работает с ошибками ниже, а затем я проверил каталог conf (/ Users / apple / GoogleDrive / project_django / venv / lib / python3 .7 / site-packages / django / conf) и обнаружил, что global_settings.py не существует в этом каталоге.
в таком случае, как мне поступить?
сделать Должен ли я сделать global_settings.py там с этим кодом ? или я смогу решить по-другому?
Не могли бы вы рассказать мне, как мне решить эту проблему?
Заранее спасибо.
__ init__. py (global_settings имеет красный lile)
Структура каталога conf
код ошибки после добавления global_settings.py в папку conf мой self
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/harvest_timer/manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 13, in <module>
from django.core.management.base import (
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/base.py", line 11, in <module>
from django.core import checks
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/checks/__init__.py", line 8, in <module>
import django.core.checks.caches # NOQA isort:skip
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/checks/caches.py", line 2, in <module>
from django.core.cache import DEFAULT_CACHE_ALIAS
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/cache/__init__.py", line 18, in <module>
from django.core import signals
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/signals.py", line 1, in <module>
from django.dispatch import Signal
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/dispatch/__init__.py", line 9, in <module>
from django.dispatch.dispatcher import Signal, receiver # NOQA
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 4, in <module>
from django.utils.inspect import func_accepts_kwargs
ModuleNotFoundError: No module named 'django.utils.inspect'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 21, in <module>
main()
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 16, in main
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
код ошибки при запуске проекта с использованием Pycharm
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 11, in <module>
from django.conf import settings
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 17, in <module>
from django.conf import global_settings
ImportError: cannot import name 'global_settings' from 'django.conf' (/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 21, in <module>
main()
File "/Users/apple/GoogleDrive/project_django/project/manage.py", line 16, in main
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
код ошибки при запуске проекта с использованием терминала
Traceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 11, in <module>
from django.conf import settings
File "/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 17, in <module>
from django.conf import global_settings
ImportError: cannot import name 'global_settings' from 'django.conf' (/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages/django/conf/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 16, in main
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
manage.py
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
Python Консоль
import sys;
...
...print(sys.path)
['/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev', '/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/third_party/thriftpy', '/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/apple/GoogleDrive/project_django/venv/lib/python3.7/site-packages', '/Users/apple/GoogleDrive/project_django']
Запуск / отладка конфигураций в Pycharm
[ Script path ]: /Users/apple/GoogleDrive/project_django/project/manage.py
[ Parameters ]:runserver
[ Environment ] variables:PYTHONUNBUFFERED=1;DJANGO_SETTINGS_MODULE=project.settings_dev
[ Python interpreter ]:Python 3.7(project_django) ~/GoogleDrive/project_django/venv/bin/python
[ Working directory ]:/Users/apple/GoogleDrive/project_django/project
Среда разработки
- Ма c: мохаве 10.14.6
- Python: 3.7.5
- Django: 2.2.2
- Pycharm: 2019.3.1 (версия для сообщества)