2

I am getting an error when I try to use syncdb:

python manage.py syncdb

Error message:

File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 83, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings '/home/simi/workspace/hssn_svn/hssn' (Is it on sys.path? Does ti have syntax errors?): Import by filename is not supported.

I'm a newbie with Django/Python, but I can't figure this error out after having researched online for a while now.

3 Answers 3

12

Your trace states:

Import by filename is not supported.

Which might indicate that you try to import (or maybe set the DJANGO_SETTINGS_MODULE) to the full python filename, where it should be a module path: your.module.settings

You could also try to specify your DJANGO_SETTINGS_MODULE directly from command line, like:

$ DJANGO_SETTINGS_MODULE=your.module.settings ./manage.py syncdb
Sign up to request clarification or add additional context in comments.

4 Comments

DJANGO_SETTINGS_MODULE is a Python module path, not a system path, so it should be 'some.dir.settings' assuming that 'some' is already on the Pythonpath.
thanks, a mistake. i corrected it; since i think trying to set the DJANGO_SETTINGS_MODULE may help finding a fix to the problem.
Ahhhh... Yes, I was exporting the entire path, so I changed it to just settings.py since the path to my project was already in sys.path. I now have other errors, but I will post different questions for that. Thank you all... You are AWESOME.
"Which might indicate that you try to import (or maybe set the DJANGO_SETTINGS_MODULE) to the full python filename" ... spot on. Thanks :)
1

Make sure your settings.py file is in the same directory as manage.py (you will also have to run manage.py from this directory, i.e. ./manage.py syncdb), or make the environment variable DJANGO_SETTINGS_MODULE point to it.

3 Comments

settings.py is in the same directory as manage.py I'm trying to set up a development area to work in and use svn to commit my changes to production. I'm using a VM running Ubuntu Jaunty (9.04) and I've been trying to set the DJANGO_SETTINGS_MODULE as an environment variable, but it does not seem to want to take it. BTW, thank you for the quick reply.
Then maybe there are errors in your settings.py file, try opening a python shell and doing "import settings" to check.
@LuperRouch that was my problem. Using the shell to determine which dependencies I'd forgotten was an excellent debugging suggestion. Problem solved. Thank you :)
1

Another thing that gives this error is permissions - very hard to track down.

Solution for me was to move <myproject> to /var/www/<myproject> and do chown -R root:root /var/www/<myproject>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.