Opened 15 years ago

Closed 15 years ago

#12730 closed (invalid)

"cannot import name utils" in "django.db.backends.postgresql_psycopg2"

Reported by: ramusus Owned by: nobody
Component: Database layer (models, ORM) Version: 1.1
Severity: Keywords:
Cc: ramusus@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

After revision http://code.djangoproject.com/changeset/12352 I got this error:

Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 252, in fetch_command
    app_name = get_commands()[subcommand]
  File "/home/ram/workspace/movister/web_site/deseb/__init__.py", line 96, in inner
    add_aka_support()
  File "/home/ram/workspace/movister/web_site/deseb/__init__.py", line 29, in add_aka_support
    import django.db.models 
  File "/home/ram/workspace/movister/web_site/django/db/__init__.py", line 75, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/home/ram/workspace/movister/web_site/django/db/utils.py", line 91, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/ram/workspace/movister/web_site/django/db/utils.py", line 49, in load_backend
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql_psycopg2' isn't an available database backend. 
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name utils

Change History (6)

comment:1 by ramusus, 15 years ago

Cc: ramusus@… added
Component: UncategorizedDatabase layer (models, ORM)

comment:2 by ramusus, 15 years ago

This error appears always when I start dev server. The reason is bad second import

from django.db import utils

inside django.db.backends.postgresql_psycopg2, I don't understand exactly why.

comment:3 by ramusus, 15 years ago

settings.py:

DATABASES = {
    'default': {
        'NAME': '...',
        'ENGINE': 'postgresql_psycopg2',
        'USER': '...',
        'PASSWORD': '...',
    }
}

comment:4 by Karen Tracey, 15 years ago

I cannot recreate this. I'm a little confused by this bit of your traceback:

  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 252, in fetch_command
    app_name = get_commands()[subcommand]
  File "/home/ram/workspace/movister/web_site/deseb/__init__.py", line 96, in inner
    add_aka_support()
  File "/home/ram/workspace/movister/web_site/deseb/__init__.py", line 29, in add_aka_support
    import django.db.models 

I do not understand why get_commands()[subcommand] is leaping off to an __init__.py file in (apparently?) one of your apps? I can see how code within get_commands might trigger load of your app's __init__.py but if that is what's happening I don't see why the line of code within get_commands isn't included in the stack trace.

What is this 'deseb'? Does it have management commands? Maybe try deleting all .pyc files and running again?

comment:5 by Karen Tracey, 15 years ago

OK, James clued me in that deseb is this: http://code.google.com/p/deseb/

and indeed if I get that and follow its instructions to include import deseb at the top of settings.py I can recreate the error.

deseb code monkeypatches django.core.management.get_commands so that's why the odd jump into deseb __init__.py in the traceback.

I'm guessing what's happening is it's forcing an import of django.db.models too early, leading to a circular import problem, but I don't have any more time to look at this right now.

comment:6 by ramusus, 15 years ago

Resolution: invalid
Status: newclosed

You are absolutely right. I remove "import deseb" from settings.py and everything became works ok.

Note: See TracTickets for help on using tickets.
Back to Top