Something in my python path must have changed because now I cannot run the.
python app/manage.py runserver
The output I get is
I agreed with OP. I met the same problem, and it turned out to be an error in settings.py
:
In settings.py I use os.environ[something]
and those environment variables are loaded in apache start script. If I run manage.py
from the command line, it doesn't know what is os.environ[something]
thus error occurs.
So for anyone here searching for solution, suggestion is to check circumstance difference between running django project and pure manage.py, maybe you'll find what's wrong.
Looking through the manager.py
code and django.core.management
I can come up with some suggestions.
First, check if the file <some_path>/django/core/management/commands/runserver.py
exists.
Second, run:
>>> import sys
>>> sys.path
If the aforementioned <some_path>
is not in this list than you must set the PYTHONPATH
variable.
Third, (and that's the longest of all shots) if you have changed the DEFAULT_PORT
of runserver
, try changing it back to 8000
.
I will add my answer to the same problem I had. This was unrelated from Django version, but in an old instance of my project I was providing my own Django copy and not installing from pip. Later I decided to use Pip installed Django.
When I pulled the changes on the server, my repo's copy of Django files were deleted but not the .pyc files. manage.py
would still import the old .pyc files making the imports break half way and the error was the same "Unknown command: runserver".
Naturally, fully deleting the folder with the .pyc files fixed the problem.
I've found the answer to my question.
If you want to diagnose this issue, run...
python app/manage.py help
... and it will show the exception. This, of course, was what was recommended by the django shell after it had told me that the command was not found.
This is clearly a bug in Django 1.4. It seems to me, an Exception should be reported regardless of what management command you run.