ModuleNotFoundError:没有名为“注册”的模块

时间:2018-09-25 08:23:52

标签: django django-registration

我在Django注册方面有问题。该软件包已正确安装,但是当我运行python3.6 manage.py runserver时,出现以下错误:

ModuleNotFoundError:没有名为“注册”的模块

我的Settings.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 :(得分:0)

我找到了解决方案。

结果表明,该应用程序在安装时能够成功运行:

pip install django-registration==2.4.1 

代替

pip install django-registration

最新的django注册版本为3.0,但2.4.1有效。只需确保卸载任何先前版本的django-registration,然后使用pip freeze > requirements.txt更新项目即可。

谢谢!

答案 1 :(得分:0)

来自docs

  

在3.x之前,django-registration安装了一个名为registration的Python模块。为了避免无提示的不兼容性,并遵循最新的最佳做法,django-registration 3.x现在安装了一个名为django_registration的模块。尝试从注册模块导入将立即失败,并显示ImportError。