8

I have many projects working in ubuntu with python2.7 and virtualenv/virtualenvwrapper, in my work some developers works with macosx and windows, generally I create the project as usual:

django-admin.py start project x

And we use svn for cvs, but in some point, without nothing rational for me, when I try something like:

python manage.py runserver

doesn't work, but is just for me and is in my laptop, that doesn't happens in productions servers or another developers.

any ideas?

I got this error:

Error: Can't find the file 'settings.py' in the directory containing 'manage.py'. It appears you've customized things. You'll have to run django-admin.py, passing it your settings module. (If the file settings.py does indeed exist, it's causing an ImportError somehow.)

But obviously, the settings file exists and is in the same folder of manage.py file, and doesn't work just for me...

This happens too with django and appengine

5
  • what does "python settings.py" say? Commented May 17, 2011 at 20:29
  • nothing, neither import settings from python interactive. Commented May 17, 2011 at 20:32
  • Strange... maybe running python in verbose mode (-v) can help you Commented May 17, 2011 at 20:38
  • Sounds like you're occasionally forgetting to activate the virtualenv. Commented May 17, 2011 at 21:24
  • Daniel, nop, i'm pretty sure I activate the virtualenv, in fact, i use virtalenvwrapper so, I do 'workon' Commented May 17, 2011 at 21:26

3 Answers 3

29

I got this error:

Error: Can't find the file 'settings.py' in the directory containing 'manage.py'. It appears you've customized things. You'll have to run django-admin.py, passing it your settings module. (If the file settings.py does indeed exist, it's causing an ImportError somehow.)

The manage.py script prints that warning whenever an import error occurs, so if your settings.py module imports stuff and that causes an import error, manage.py will still print that warning.

One way to diagnose would be to (temporarily) change manage.py from

#!/usr/bin/env python
from django.core.management import execute_manager
try:
    import settings # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
    sys.exit(1)

if __name__ == "__main__":
    execute_manager(settings)

to

#!/usr/bin/env python
from django.core.management import execute_manager
import settings # Assumed to be in the same directory.

if __name__ == "__main__":
    execute_manager(settings)

and see the stack trace that is printed when running $ python manage.py runserver.

Sign up to request clarification or add additional context in comments.

Comments

3

If you are getting this error when trying to get started with django and appengine, whilst following the guide at http://www.allbuttonspressed.com/projects/djangoappengine

and you created symlinks to the folders, the guide is wrong whilst creating the djangoappengine symlink. You need to go 1 directory e.g.

NOT:

Copy the following folders into your project (e.g., django-testapp):

django-nonrel/django => <project>/django
djangotoolbox/djangotoolbox => <project>/djangotoolbox
django-autoload/autoload => <project>/autoload
django-dbindexer/dbindexer => <project>/dbindexer
djangoappengine => <project>/djangoappengine

FIXED:

Copy the following folders into your project (e.g., django-testapp):

django-nonrel/django => <project>/django
djangotoolbox/djangotoolbox => <project>/djangotoolbox
django-autoload/autoload => <project>/autoload
django-dbindexer/dbindexer => <project>/dbindexer
djangoappengine/djangoappengine => <project>/djangoappengine

Notice the last line.

2 Comments

I was following blog.abhijeetr.com/2013/02/… tutorial, same thing, getting another error now: TypeError: __init__() takes exactly 1 argument (2 given)
problem solved, a great way to get django + gae running is to use this script seperohacker.blogspot.com/2012/05/…
1

I hunted all thru the django code for an hour until I came across this:

manage.py [command] --traceback

Turns out there was an import error deep in my app. Once I could see the error, it took ten seconds to fix. :/

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.