Django allauth 和 ImportError

Django allauth and ImportError

我刚刚完成了这个介绍,当我尝试时

./manage.py migrate

我收到这个错误:

Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/me0o/work/v_venv/local/lib/python2.7/site-packages/allauth/socialaccount/providers/__init__.py", line 2, in <module>
from django.utils import importlib
ImportError: cannot import name importlib

我有 Django 1.9.2 我有最新版本的 importlib 有什么想法吗?

django.utils.importlib 在 Django 1.7 中弃用并在 Django 1.9 中删除。

由于allauth出现错误,请将django-allauth升级到最新版本。根据changelog,版本0.24.0应该支持Django 1.9。

改变你的

from django.utils import importlib

至:

from importlib import import_module