David Haddad
David Haddad

Reputation: 3946

Nothing happens when I do: python manage.py command

I'm new to django and currently going through the main tutorial. Even though it was working earlier, when I do python manage.py runserver OR python manage.py -h OR with any other command, the shell doesn't output anything. Wondering what I'm doing wrong.

Upvotes: 5

Views: 19511

Answers (13)

Dmitrijs Čornobiļs
Dmitrijs Čornobiļs

Reputation: 953

Ensure that you have established successfully database connection

Upvotes: 0

Raadin.stack
Raadin.stack

Reputation: 1

I think the problem is in manage.py file (50%), check it with an another file that is correct.

Upvotes: 0

Raadin.stack
Raadin.stack

Reputation: 1

I think the problem is in manage.py file, check it with

Upvotes: 0

Tiago Peres
Tiago Peres

Reputation: 15622

Another solution, if you can, is to upgrade Django

pip install django --upgrade

Oftentimes one will get other unrelated issues to solve that are linked with the upgrade but once all is fixed the server should run just fine.

If you can't upgrade Django, this problem also happens when the code was built using Python 2.x and you're locally using Python 3.x.

The quicker fix in that case is to uninstall Python 3.x from your machine and make sure Python 2.x was added to the path. I've seen some developers setting up alias in PowerShell to have more than one version in the environment too.

Upvotes: 0

Sujan DevTips
Sujan DevTips

Reputation: 11

Please try this.

  1. Uninstall Python.
  2. Go inside C drive and search Django. You will get many Django related files.
  3. Delete every Django file. 😁 don't delete your Django files.
  4. Install Python.

It's worked for me.

Upvotes: 1

Amandeep
Amandeep

Reputation: 41

The same happened with me also, but this issue is a minor one as it happens if you have multiple versions of Python on your system, you can select a specific Python version by running python3 or whichever version you want. SO you should start from the beginning, uninstall Django first then, create a virtual environment, decide upon a directory where you want to place it, and run the venv module as a script with the directory path:

for e.g: python3 -m venv tutorial-env

//This will create the tutorial-env directory if it doesn’t exist, and also create directories inside it Once you’ve created a virtual environment, you may activate it.

On Windows, run:

tutorial-env\Scripts\activate.bat On Unix or MacOS, run:

source tutorial-env/bin/activate

Now, In the command prompt, ensure your virtual environment is active, and execute the following command:

...> py -m pip install Django

NOTE: If django-admin only displays the help text no matter what arguments it is given, there is probably a problem with the file association in Windows. Check if there is more than one environment variable set for running Python scripts in PATH. This usually occurs when there is more than one Python version installed.

Upvotes: 0

Shahaz
Shahaz

Reputation: 1

if you are using Redis Server on Windows, check it out if Redis Server is running, I had same problem and realized my Redis Server was not running, I ran it and now my manage.py commands work fine.

Upvotes: 0

Chaime
Chaime

Reputation: 181

The problem is that the first line in manage.py breaks the file on windows. The first line should look like this:

#!/usr/bin/env python

Removing it will fix the issue.

Upvotes: 18

Surya Chereddy
Surya Chereddy

Reputation: 1061

Just stuck with the same problem. Found a solution that works, but tedious.

You need to know the location of the python.exe file in your computer. It is usually C:/Users/USERNAME/AppData/Local/Programs/Python//python.exe

Modify as required and run the following in CMD,

C:/Users/USER1/AppData/Local/Programs/Python/Python38-32/python.exe
F:/mysite/manage.py runserver

Hope this works :)

Upvotes: 0

israteneda
israteneda

Reputation: 775

On Ubuntu works for my by running manage.py as script:

./manage.py runserver

Upvotes: 0

Orkhan Shirin
Orkhan Shirin

Reputation: 59

if you created a virtual environment then activate it. you can try this command(in virtual environment directory) if you're using windows os:

.\Scripts\activate

Upvotes: 0

Jai Sharma
Jai Sharma

Reputation: 733

If you had your server running till one point and a certain action/change broke it, try going back to the previous state.

In my case there was an email trigger which would put the system in an invalid state if email doesn't go through. Doing git stash followed by selectively popping the stash and trying the runserver helps narrow down the problem to a particular file in your project.

Upvotes: 1

phemios
phemios

Reputation: 674

First, check if python is fully installed by typing "python" in a shell.

Then you should try python manage.py runserver inside your django project. If you don't have any django project, try creating one by typing django-admin.py startproject mysite. If nothing is displayed in your shell, you must have installed Django the wrong way.

Please refer to Django Documentation at https://docs.djangoproject.com/en/1.4/intro/install/

Upvotes: 3

Related Questions