来自django.db import utils ImportError:无法导入名称utils

时间:2013-03-06 18:46:48

标签: django

当我尝试从ConceptNet导入模块时(来自conceptnet.models导入概念),我收到此错误消息:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/conceptnet/models.py", line 2, in <module>
from django.db import models
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 40, in     <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 34, in    __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in   import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2  /base.py", line 9, in <module>
from django.db import utils
ImportError: cannot import name utils

为了确保这个问题不是由ConceptNet中的某些东西引起的,而是由django.db引起的,我试过,导入django.db,这足以给我同样的错误。有些东西告诉我这里有一些循环:import django.db设置了一些动态,在某些时候试图从django.db导入一些东西。我不知道怎么做这个工作?

1 个答案:

答案 0 :(得分:0)

请参阅:django-error #16136

检查您是否使用较新版本的Django

检查settings.py中的DATABASE CONFIG:

DATABASES['default'] =  {
    'ENGINE':   'django.db.backends.postgresql_psycopg2',

检查您的托管服务提供商是否已正确设置数据库