From django.db import utils ImportError cannot import utils name?

I am in a simple python shell and I get this error when trying to import my project models:

from results.models import TestResult Traceback (most recent call last): File "C:\Program Files (x86)\Wing IDE 3.2\src\debug\tserver\_sandbox.py", line 1, in <module> # Used internally for debug sandbox under external interpreter File "C:\Users\audrey_moreau\myProject\results\models.py", line 1, in <module> from django.db import models File "c:\Python27\Lib\site-packages\django\db\__init__.py", line 40, in <module> backend = load_backend(connection.settings_dict['ENGINE']) File "c:\Python27\Lib\site-packages\django\db\__init__.py", line 34, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "c:\Python27\Lib\site-packages\django\db\utils.py", line 92, in __getitem__ backend = load_backend(db['ENGINE']) File "c:\Python27\Lib\site-packages\django\db\utils.py", line 54, in load_backend return import_module('.base', backend_name) File "c:\Python27\Lib\site-packages\django\utils\importlib.py", line 35, in import_module __import__(name) File "c:\Python27\Lib\site-packages\django\db\backends\sqlite3\base.py", line 14, in <module> from django.db import utils ImportError: cannot import name utils 

Can someone give me a pointer on how to fix this? I am using Python 2.7.

+7
source share
4 answers

I had this error and it was called by django_nose. I tried to import django_nose from settings.py to determine if it exists on the system as follows:

 try: import django_nose INSTALLED_APPS += ['django_nose'] TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' except ImportError: pass 

I changed it to

 from imp import find_module try: find_module('django_nose') INSTALLED_APPS += ['django_nose'] TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' except ImportError: pass 

and my problem was solved ...

+1
source

I do not know the exact reason, but using Django python shell ie {$. / Manage.py shell} does not throw an error. I think Django has a little tweak / unset of python packages, hence the bickering in the traditional interpreter.

+1
source

I had the same error. Uninstalling and reinstalling django took care of this:

 sudo pip uninstall django sudo pip install django 
0
source

add django to your sys path. I had a similar problem and it worked for me.

0
source

All Articles