ModuleNotFoundError: нет модуля с именем «регистрация» - PullRequest
0 голосов
/ 25 сентября 2018

У меня проблема с Django-Registration.Пакет установлен правильно, однако, когда я запускаю python3.6 manage.py runserver, я получаю следующую ошибку:

ModuleNotFoundError: Нет модуля с именем 'registration'

Снимок экрана моих настроек.Файл py, Urls.py и HTML-шаблон прилагается ниже: [введите описание изображения здесь] [1]

Выполнение системных проверок ...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10df3cb70>

Traceback (most recent call last):
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
    return import_module(self.urlconf_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/melissamalala/PycharmProjects/moringatribune/tribune/urls.py", line 25, in <module>
    url(r'^accounts/', include('registration.backends.simple.urls')),
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/conf/urls/__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'registration'
^CTraceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 13, in <module>
(venv) Melissas-MacBook-Pro:moringatribune melissamalala$ python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10d9da8c8>
Traceback (most recent call last):
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/Users/melissamalala/PycharmProjects/moringatribune/venv/lib/python3.6/site-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'registration'


  [1]: https://i.stack.imgur.com/pkJQZ.jpg

Ответы [ 2 ]

0 голосов
/ 10 ноября 2018

Из документов :

До версии 3.x django-registration устанавливал модуль Python с именем registration.Во избежание несовместимости без вывода сообщений и в соответствии с более поздними лучшими практиками, django-registration 3.x теперь устанавливает модуль с именем django_registration.Попытки импортировать данные из модуля регистрации немедленно завершатся неудачей с помощью ImportError.

0 голосов
/ 25 сентября 2018

Я нашел решение.

Оказывается, приложение может успешно работать при установке:

pip install django-registration==2.4.1 

вместо

pip install django-registration

Последняя версия регистрации django - 3.0, но 2.4.1 работает.Просто убедитесь, что вы удалили предыдущую версию django-registration, а затем обновили свой проект до pip freeze > requirements.txt.

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...