views:

2277

answers:

7

I've got the following installed through MacPorts on MacOS X 10.5.6:

py25-sqlite3 @2.5.4_0 (active)
python25 @2.5.4_1+darwin_9+macosx (active)
sqlite3 @3.6.12_0 (active)

python25 is correctly set as my system's default Python.

I downloaded a fresh copy of Django 1.1 beta (I have the same problem with 1.0 and trunk, though) and installed it with "sudo python setup.py install".

Things seem to load correctly through the interactive interpreter:

$ python
Python 2.5.4 (r254:67916, Apr 10 2009, 16:02:52) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> import sqlite3
>>> ^D

But:

$ django-admin.py startproject foo
$ cd foo/
$ python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x6c1e70>
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
    self.validate(display_num_errors=True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 246, in validate
    num_errors = get_validation_errors(s, app)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
    from django.db import models, connection
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/__init__.py", line 22, in <module>
    backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, [''])
ImportError: No module named dummy.base

If I change DATABASE_ENGINE in settings.py to "sqlite3", I get the following, seemingly related problem:

$ python manage.py runserver

Validating models...
Unhandled exception in thread started by <function inner_run at 0x6c1e70>
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
    self.validate(display_num_errors=True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 246, in validate
    num_errors = get_validation_errors(s, app)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
    from django.db import models, connection
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/__init__.py", line 22, in <module>
    backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, [''])
ImportError: No module named base
^C$

I swear this all worked a few days ago and I don't recall changing anything related to Django or Python, installation-wise.

My various Google adventures have turned up nothing useful. So... Any ideas?

Edit: 'syncdb' raises the same exceptions.

A: 

did you try the intro doc? doc link

If you follow this doc, you can at least say, "at step XXXX it got error YYY". Then someone with some experience (no me) should be able to find a good answer. This link is for the trunk, there's a link for 1.0 docs at the top.

Well, you can infer it from my question, but if you want a doc reference, here's where I start seeing exceptions: "Change into the mysite directory, if you haven't already, and run the command python manage.py runserver."
Tyson
A: 

duh, i'm not thinking. Just run

python manage.py syncdb

this will build you db so you can then run the server.

I should have mentioned that 'syncdb' throws the same exact errors.
Tyson
A: 

Re-check your settings.py. In the second case, it looks like your DATABASE_ENGINE is set to the empty string, not 'sqlite3'.

Carl Meyer
Neither work. Not to mention, Django allows you to not specify a database backend, anyways.
Tyson
I'd say you've managed to hose your Django install somehow.
Carl Meyer
I've re-installed it from scratch -- still no luck. :/
Tyson
+1  A: 

I found this thread on the Django Users group:

They suggest that it has something to do with the way MacPorts installs Python. I wish I had more details to help you with, but as a workaround, I recommend you use MacPorts to uninstall this copy of Python and try to use alternate method of install it. If you're looking for an quick and easy install, you might want to try MacPython. Hope this helps!

bchang
I'll give this a shot later today.
Tyson
Please tell me this worked?
bchang
Yeah, blew MacPorts away and just installed everything -- Python, PIL, SQLite, pysqlite, etc. -- from official sources. Enjoy the bounty! :)
Tyson
A: 

This isn't an answer, exactly, but I would try removing the MacPorts install of Django and start over. Then try adding easy_install and using that to install everything. To make things cleaner and easier to start over, you might also want to add virtualenv, which lets you set up multiple self-contained Python environments.

Tom
I didn't use MacPorts' Django in the first place. I've tried fresh installs of the 1.0 and 1.1 versions from Django's site -- no dice.
Tyson
Sorry, I meant remove Django and just saw "MacPorts" in there as well. Have you tried easy_install? That's made my Python-/Django-related installs a lot smoother.
Tom
Yeah, tried easy_install. Same thing. Argh!
Tyson
A: 

You can also try installing the py25-hashlib package if you don't have it already. I found this described on the django bug tracking site.

Normally, this package is part of python, but it's either missing or wrong in the macports version, from what I've read.

I found more info on the macports version of py25-hashlib here.

landyman
A: 

Try using the full path to python as well as checking the module path

trent