Opened 14 years ago
Last modified 13 years ago
#16136 closed Uncategorized
Error was: cannot import name utils — at Version 7
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Uncategorized | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | ognajd@… | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 141, in get_response
return self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 165, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/lib/python2.5/site-packages/django/views/debug.py", line 58, in technical_500_response
html = reporter.get_traceback_html()
File "/usr/lib/python2.5/site-packages/django/views/debug.py", line 137, in get_traceback_html
return t.render(c)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 173, in render
return self._render(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 167, in _render
return self.nodelist.render(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 796, in render
bits.append(self.render_node(node, context))
File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 72, in render_node
result = node.render(context)
File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 89, in render
output = self.filter_expression.resolve(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 579, in resolve
new_obj = func(obj, *arg_vals)
File "/usr/lib/python2.5/site-packages/django/template/defaultfilters.py", line 697, in date
return format(value, arg)
File "/usr/lib/python2.5/site-packages/django/utils/dateformat.py", line 281, in format
return df.format(format_string)
File "/usr/lib/python2.5/site-packages/django/utils/dateformat.py", line 30, in format
pieces.append(force_unicode(getattr(self, piece)()))
File "/usr/lib/python2.5/site-packages/django/utils/dateformat.py", line 187, in r
return self.format('D, j M Y H:i:s O')
File "/usr/lib/python2.5/site-packages/django/utils/dateformat.py", line 30, in format
pieces.append(force_unicode(getattr(self, piece)()))
File "/usr/lib/python2.5/site-packages/django/utils/encoding.py", line 66, in force_unicode
s = unicode(s)
File "/usr/lib/python2.5/site-packages/django/utils/functional.py", line 206, in __unicode_cast
return self.__func(*self.__args, **self.__kw)
File "/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py", line 55, in ugettext
return real_ugettext(message)
File "/usr/lib/python2.5/site-packages/django/utils/functional.py", line 55, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
File "/usr/lib/python2.5/site-packages/django/utils/translation/__init__.py", line 36, in delayed_loader
return getattr(trans, real_name)(*args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py", line 276, in ugettext
return do_translate(message, 'ugettext')
File "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py", line 266, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py", line 176, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/lib/python2.5/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/usr/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/__init__.py", line 1, in <module>
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "/usr/lib/python2.5/site-packages/django/contrib/admin/helpers.py", line 1, in <module>
from django import forms
File "/usr/lib/python2.5/site-packages/django/forms/__init__.py", line 17, in <module>
from models import *
File "/usr/lib/python2.5/site-packages/django/forms/models.py", line 6, in <module>
from django.db import connections
File "/usr/lib/python2.5/site-packages/django/db/__init__.py", line 77, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/usr/lib/python2.5/site-packages/django/db/utils.py", line 91, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/lib/python2.5/site-packages/django/db/utils.py", line 49, in load_backend
raise ImproperlyConfigured(error_msg)
TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.mysql' 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 (7)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
| Type: | Uncategorized → Bug |
It works for me, and there really isn't enough information to work out why it this is happening. The only thing I can suggest is that Django has not been installed properly or fully. Clearly the 'mysql' directory exists, otherwise you would not get that error message, but it must be broken in some way, and this might not be anything to do with the code that we released.
Please re-open if you can provide enough information for us to work out why this is happening, and it is a bug in Django. A command like this might help:
DJANGO_SETTINGS_MODULE='your_settings.py' python2.5 -c 'import django.db.backends.mysql.base'
comment:3 by , 14 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → reopened |
| Type: | Bug → Uncategorized |
Thanks for the feedback. Here is what I am getting now. The code you suggested is in *deployment.wsgi* towards the end.
In deployment.wsgi:
#!/usr/bin/python
import os
import sys
LIB_ROOT = "/var/www/userXXX/files/"
PROJECT_PKG = "myproject-0.2"
PROJECT_SETTINGS = 'myproject.settings'
DJANGO_PATH = "/usr/share/django/Django-1.3"
MESSAGES_PKG = "django_messages-0.4.4"
REGISTRATION_PKG = "django_registration-0.7"
TAGGING_PKG = "django_tagging-0.3.1"
MARKDOWN_PKG = "Markdown-2.0.3"
PYGMENTS_PKG = "Pygments-1.4"
PACKAGES = dict((
## Comment this out to use the latest stable
("django", DJANGO_PATH),
("myproject", os.path.join(LIB_ROOT, PROJECT_PKG)),
("messages", os.path.join(LIB_ROOT, MESSAGES_PKG)),
("registration", os.path.join(LIB_ROOT, REGISTRATION_PKG)),
("tagging", os.path.join(LIB_ROOT, TAGGING_PKG)),
("markdown", os.path.join(LIB_ROOT, MARKDOWN_PKG)),
("pygments", os.path.join(LIB_ROOT, PYGMENTS_PKG)),
))
if "django" in PACKAGES:
path = PACKAGES.pop("django")
sys.path.insert(0, path)
for name, path in PACKAGES.items():
try:
__import__(name, globals())
except ImportError, e:
if not path in sys.path:
sys.path.insert(0, path)
for name, ignore in PACKAGES.items():
try:
__import__(name, globals())
except ImportError, e:
raise
os.environ['DJANGO_SETTINGS_MODULE'] = PROJECT_SETTINGS
import django.db.backends.mysql.base
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
In error_log:
File "/var/www/mars98/html/kurvenschubser/deployment.wsgi", line 61, in <module>
import django.db.backends.mysql.base
File "/usr/share/django/Django-1.3/django/db/__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/usr/share/django/Django-1.3/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/share/django/Django-1.3/django/db/utils.py", line 33, in load_backend
return import_module('.base', backend_name)
File "/usr/share/django/Django-1.3/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/share/django/Django-1.3/django/db/backends/mysql/base.py", line 28, in <module>
from django.db import utils
ImportError: cannot import name utils
comment:4 by , 14 years ago
looks like a circular import, I guess.
I tried versions 1.2.5 and 1.1.1 as well, it's the same issue.
comment:6 by , 14 years ago
I found that this error occurred for me when I migrated files from another server, but forgot to change template path. I fixed the path, and the error stopped. I think a munged path in the settings file causes this.
comment:7 by , 14 years ago
| Description: | modified (diff) |
|---|
When importing django.db.backends.mysql.base:
django/db/__init__.pyexecutes successfullydjango/db/__init__.py:- imports
ConnectionHandlerfromdjango.db.utils- at this point the
utilsmodule fromdjango.dbis imported and working.
- at this point the
- runs
connections = ConnectionHandler(settings.DATABASES) - reaches
connection = connections[DEFAULT_DB_ALIAS]which appears in the traceback above.
- imports
- at the bottom the traceback,
django/db/backends/mysql/base.pyfails to importutilsfromdjango.db.
This is just weird.
Did you try to contact your hosting provider's technical support? Since it's a shared host, I guess you're using a version of Django installed by them at the system level. You must not be the only one trying to use Django with MySQL.
This happens right on startup on a shared hosting provider. I am finding the traceback message unhelpful, since I am using "django.db.backends.mysql" in the settings.py and MySQLdb is definitely installed.