Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6732521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:39:39+00:00 2026-05-26T10:39:39+00:00

I’m a django newbie. I just installed v 1.3.1 on windows vista (using setup.py

  • 0

I’m a django newbie. I just installed v 1.3.1 on windows vista (using setup.py install) for python 2.5

When I start a python shell and try to import django.db I get the following circular import error

>>> import os
>>> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>>> import django.db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python25\lib\site-packages\django\db\__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
  File "C:\Python25\lib\site-packages\django\db\utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
  File "C:\Python25\lib\site-packages\django\db\utils.py", line 33, in load_backend
return import_module('.base', backend_name)
  File "C:\Python25\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Python25\Lib\site-packages\django\db\backends\sqlite3\base.py", line 14, in <module>
    from django.db import utils
ImportError: cannot import name utils
>>>

Looking at the code, I can see that django\db\backends\sqlite3\base.py imports django\db\utils.py, but then this file also imports base.py (using import_module). Isn’t that necessarily going to crash due to circular import?

On the other hand, if I use the shell from python manage.py shell everything works fine, so there must be something I can run on my plain shell to make it work

Thanks for any hints!

EDIT:

Delyan came up with two possible solutions:

C:\Users\xulo>cd c:\django_example
c:\django_example>cd mysite
c:\django_example\mysite>python
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>>> import sys
>>> sys.path.append('c:\\django_example\\mysite')
>>> sys.path.append('c:\\django_example')
>>> from django import db
>>>

or

c:\django_example\mysite>python
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import settings
>>> import django.core.management
>>> django.core.management.setup_environ(settings)
'c:\\django_example\\mysite'
>>> from django import db
>>>

Both work well, but I’ll leave the question open for now to see if someone has a simple explanation of why, and why that sorts the apparent circular import between utils.py and base.py

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:39:40+00:00Added an answer on May 26, 2026 at 10:39 am

    It’s rather annoying but Django wants you to have your project’s folder and its parent in sys.path. You can see this happening in setup_environ in django.core.management.__init__

    There was an issue raised recently and this might be refactored in the near future but for now just add those two folders to any custom scripts (though you should really be adding them as manage.py commands).

    Edit: This has been partially refactored in Django 1.4.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.