Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.4 Unknown command: 'runserver'

Something in my python path must have changed because now I cannot run the.

python app/manage.py runserver

The output I get is

Unknown command: 'runserver'
Type 'manage.py help' for usage.

I've looked at my environment's PYTHONPATH and PATH variables, but I can't figure out why its not running.

like image 669
Ryan Pfeffer Avatar asked Feb 14 '13 22:02

Ryan Pfeffer


People also ask

What does django Runserver do?

The runserver command is a built-in subcommand of Django's manage.py file that will start up a development server for this specific Django project.

How do I know if django server is running?

To verify the Django project, make sure your virtual environment is activated, then start Django's development server using the command python manage.py runserver . The server runs on the default port 8000, and you see output like the following output in the terminal window: Performing system checks...

How do I disable django?

Though the message in the console states that Ctrl+Break should be used to quit the server, it is not possible; one can only use Ctrl+F4 works to close the console.


2 Answers

I've found the answer to my question.

  • If you've got an error in your settings, manage.py will swallow the exception and report as if the command does not exist.
  • This lead me down the path of incorrectly assuming my python path or venv environment was messed up.

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.

like image 73
Ryan Pfeffer Avatar answered Oct 14 '22 06:10

Ryan Pfeffer


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.

like image 32
dmg Avatar answered Oct 14 '22 05:10

dmg