Python manage.py runserver not working


#1

Working in Powershell w Win10. Runserver command worked ok until I added my gitignore file.

Now when command is entered, computer thinks about it, and then just returns a new line with directory info.

A Google search indicates others have had this problem and it is somehow related to environment variables but I’m still not clear on what needs to be done.

Can anyone help?


#2

Hi,
It might be that your python.exe is not in your path, so when you type ‘python manage.py runserver’, it is not finding it.
What exactly is the error message?


#3

No error message. It simply returns to the command prompt without an error message. It was working. Then I set up the .gitignore file and it promptly stopped working. I moved the .gitignore file out of the directory but that did not help. Same result. Bizarre.


#4

HI,

Sorry I just noticed that in another post you were questioning the different python versions. In actual fact, python 2.x and python 3.x are both being developed at the same time but a lot of the libraries and other programs have not yet been ported to use python 3. In the python section near the beginning of the book Tracy has indicated that we should use python 2 for this project, otherwise things might not play ball properly:-

Oh, and we’re using Python 2.7. Python 3 is out, but not a lot of
beginner-friendly plugins have been ported over. Python 2.7 is
still very widely used so we’re sticking with that for now.

The .gitignore file is not essential for the running of the server. It just tells git what not to check-in.
On the commandline in PS, can you confirm what happens when you just type python ?. Do you get the following? If not then you have something wrong with your Python installation. What version of Python are you actually running?

PS C:\Users\David> python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

If you do get the above, then could you please post what you have in you .gitignore file.
Also what happens when you type http://127.0.0.1:8000 in your web browser address bar after you have executed python manage.py runserver - what does the output say in the browser? Also could you post the output of the powershell after you type this?
Also as a check, If you right-click your the clock at the right of your windows status bar and select Task Manager, you should see python.exe in you list of running processes under background processes. If not then there is an issue with your python.

To be able to identify your problem properly and quickly, we really need more information which will involve you posting what code you have so far, including your settings.py, urls.py, models.py and views.py. However, at the moment, you don’t seem to be getting that far.
Without the info we are clutching at straws and playing a guessing game.

Regards
David


#5

Hi David:
Thanks for your help.

I’m running 3.6.1. I understand the tutorial is supposed to be done on 2.7 but I tried and I couldn’t get that pip thing to work when using 2.7. 3+ has that already installed and works like a charm.

In face, the whole thing worked like a charm - I even got to the point where I changed the background color of the web page. Why would it work for half a dozen times and then suddenly stop working for no apparent reason? Doesn’t make sense.

I saw python.exe listed under background processes in the task manager once but it isn’t there now.

screenshots of error messages attached.

I have all my code on atom. I can share it that way, yes?


#6


#7

Hi @4SandyD, are you restarting your server in your command line? The python manage.py runserver command. :)


#8

Yes. In the (venv)C:\users\alessandra\projects\myhellowebapp


#9

In the command line window where you run the command python manage.py runserver, you should also see a text output of errors. Can you paste in what it says when you get the browser errors that you screenshot-ed above?


#10

Wonder is PowerShell itself could be masking any output. I would try and run in an a windows ‘elevated’ command prompt and see if any output is shown.


#11

You can also try to just type in “python manage.py” and see some output?
I gather that “python manage.py shell” still works?


#12

Right — @4SandyD, if you could take a screenshot of your powershell, that’d be super helpful. :)


#13

what if it restarted?
how can we go to that path using that environment variable
i’m a beginner
please help


#14

Hello All,

I am also new to python & Django framework. I was also facing similar issue as explained earlier - “python manage.py runserver” was not doing anything. There was no clue - no error message.

I tried to redirect error message on my windows command prompt:
python manage.py runserver 2>error.txt

On executing this, I saw error.txt created there and it contains the error. Actually, it was unable to find python. That’s a seprate issue.

For the timebeing, I just use the absolute path of my python installation to run this and it worked for me, like:

C:\Users\YOUR_USER_NAME\AppData\Local\Programs\Python\Python39\python.exe .\manage.py runserver