I am new to stackoverflow, very new to Python and trying to learn Django.
I am on Windows 10 and running commands from powershell (as administrator).
I am in a virtual environment. I am trying to set up Django.
I have run the following commands
"pip install Django"
"django-admin.py startproject learning_log ."
"python manage.py migrate"
All of the above seemed to work okay, however, when I then try to run the command
"python manage.py runserver"
I get a popup error box that says:
Python has stopped working
A problem caused the program to stop working correctly.
Windows will close the program and notify you if a solution is available.
Can someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?
I finally got the "python manage.py runserver" command to work. The only thing different I did was before setting up the virtual env and installing Django was set my executionpolicy to Unrestricted. Previously it had been set to RemoteSigned. I hadn't been gettiing any warning or errors but thought I would try it and it worked.
I encountered the same problem. After trying everything, I switched from PS to cmd, cd to the same directory and run python manage.py runserver. Then it worked. Then I ctrl+C quit the server, switched back to PS, ran the command, it still threw the same dialog window (Python stopped working). Then I went back to cmd, typed the command and the server started fine.
Conclusion: Use cmd to run the command, not PS.
Related
So I am trying to deploy a python Django project on windows server 2012R2. But when trying to run the command I get this error.
When trying to open the link in IIS manager it show error 500.
I am running command prompt as administrator but that did not solve the problem.
Python version:3.8.8
IIS 8
If you need to know version of any other library to answer please comment.
Try to run the wfastcgi-enable.exe in command prompt as system administrator
write "cmd" on windows start, then right click and run the command prompt as administrator. then go to the directory where your python environment install the fastcgi . then run the wfastcgi-enable.exe command
That is how I made it work.
I am building a website using Django and wanted to inspect my database using command: python manage.py dbshell however surprisingly I got CommandError: You appear not to have the 'sqlite3' program installed or on your path. I am using VS Code for my project and got the error in command prompt terminal of VS Code.
I am saying surprisingly because I have already created my models before with commands python manage.py makemigrations and python manage.py migrate. These commands also don't work right now.
It is impossible that sqlite3 is not installed because python installs it inherently. I assume PATH variable is also not an issue as I added it and can run sqlite3 outside of VS Code if I open command prompt from the start menu of windows.
What can be the reason of this corruption/problem and how can I fix it ?
This is screenshot of start menu command prompt :
This is screenshot of VS Code :
I have a big problem wih Django3: basically, whenever I type a command for manage.py, the prompt gets stuck and never carries on the command without even crashing.
I tried several times the commands "runserver" and "startapp" and waited beetween 10 minutes and an hour, but I never managed to run the server or create an app because I launch the command and the prompt gets stuck.
Strangely enough, to test things out, I created a project, an app and run the server immediately after I installed Django3 and everything worked fine, I even have that project on github. Then I shut down the computer and now nothing works, except my test project.
Also, I noticed in the Windows resource monitor that whenever I try to lauch a command suddenly Python processes start to appear and disappear uncontrollably, and since I never had an issue like this I'm absolutely clueless about everything. So... What's happening? Did someone have the same problem?
I have the lastest Windows update, the latest Python3 (I got it via Windows Store) and the Latest Django3 (I got it via pip). I'd include a stacktrace or some sort of log but, since nothing crashes, I suppose no log gets done: if I'm wrong please correct me, please!
EDIT: I tried uninstalling and installing Python but the problem is the same: I created a test project and I successfully ran the server and started a new app. Once again, I shut down the computer and now everything is broken again.
Ok, thanks to ansuman I discovered virtual environments and now everything works again.
If you're a noob like me and you want to know more go check the virtual environments documentation, it's extremely helpufl if you're experiencing (supposed) module conflicts like me. Also, it's such a cool feature: start using venv now, you won't regret it.
Here's what I did step-by-step:
opened the command prompt (duh);
installed venv via pip;
created a folder for the virtual environment with python -m venv site-venv;
went into the newly created directory;
created a new Django project with django-admin startproject site;
went into the subdirectory Scripts of site-venv and typed activate;
with the virtual environment activated, installed Django via pip;
started doing all the manage.py stuff.
Hope this help someone! Thanks again to ansuman.
Whenever I use python manage.py runserver on Windows PowerShell it causes Python to crash: "Python has stopped working" window pops up. Any idea why?
I've tried rebooting, which causes a different type of error:
python.exe: can't open file '.\maanage.py': [Errno 2] No such file or directory.
I created another project and tried runserver and again it caused the first error. All installation commands ran smoothly, but why am I facing this error?
Make sure you're spelling the file name correctly.
maanage.py != manage.py
So I've been following this django tutorial, and I've been running into some issues with the manage.py commands when using a git bash terminal. I'm using Python 2.7.11 (Anaconda 2.4.1), Django 1.9.5 and git 2.8.1.windows.1 on Windows 10.
Specifically the python manage.py runserver and the python manage.py shell commands don't appear to work properly using a git bash terminal, but they do work when using an Anaconda terminal. I'd like to find a way to get it working with git bash.
According to the tutorial, I should see this output on terminal when running python manage.py runserver:
Performing system checks...
System check identified no issues (0 silenced).
April 19, 2016 - 15:50:53
Django version 1.9, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Using git bash, I know that SOMETHING is working because I can navigate to http://127.0.0.1:8000/ in my browser. I just don't see any output on the terminal.
I continued along with the tutorial, because this didn't really affect anything. It appears to work, just no terminal output. Then I got to this part of the tutorial, where you open a shell with python manage.py shell.
Using git bash, nothing happens. The shell prompt never opens, as if it's stuck. No errors, just a blinking cursor on a new line without a command prompt. If I do the same thing using the Anaconda terminal, the shell opens fine.
At first I thought it was an installation error. So, I attempted to install django using both pip install and conda install, but I still get the same problems. I'm not really sure what's going on here, and I haven't managed to find a solution yet.
Any help is greatly appreciated.
Update:
I found a similar question that doesn't quite have a solution, but it recommends using pystuck to debug. I read the pystuck docs but don't quite understand how to use it for this problem in particular.
I have this problem too, when running python manage.py runserver the verbose output is missing, only high level page responses are present. I was using powershell or Git Cmd, that is an option... This fix also resolves issues with using Git Bash to python manage.py makemigrations and python manage.py migrate,
Option: Use Git Cmd or powershell.
Temp Fix: Run this command in Git Bash to generate verbose output for this working session: alias python='winpty python.exe'
Perm Fix: Use the temp fix in a .bashrc file, git bash will always have verbose output.
cd ~ #Takes you to your root directory.
touch .bashrc
Edit the file using VIM, or editor of your choice, add the following line (note: Notepad from MS Windows will not save this file correctly. Do not use notepad.):
alias python='winpty python.exe'
Restart Git Bash.
Note:
In some circumstances, you will get one prompt when you launch git bash:
"WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or
~/.profile.
This looks like an incorrect setup. A ~/.bash_profile that
loads ~/.bashrc will be created for you."
You will notice a second file .bash_profile was created for you and you are good to go!
That's it... enjoy.
I don't know why but I found a bit of a workaround. When running python manage.py runserver in the Git Bash window on windows 7 (using Anaconda2) I also DID NOT get the expected:
Performing system checks...
System check identified no issues (0 silenced).
February 09, 2017 - 17:39:48
Django version 1.10.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8090/
Quit the server with CTRL-BREAK.
Doing the same in the native windows CMD prompt worked!!!
I had manage.py open in Sublime Text and when I saved it (or any other file in the project) the server (started and currently frozen in the git bash window) started up as expected.
Maybe this will work for you. Don't know why it does or should...