I've tried searching for why this keeps happening as I think I've seen others mention this problem.
Whenever I run manage.py runserver
from the command line, it just opens the manage.py file from the project directory in notepad. If I include python in the beginning of the command, it says that 'python' is not recognized as an internal or external command, operable program or batch file.
I'm using windows now. I was running linux before and it was working fine...I just transferred all the files that I was working on onto windows and that's when this problem started happening.
To reiterate, the only thing that happens when I run the runserver command is that the manage.py file opens in notepad and it contains the following:
#!/usr/bin/env python
from django.core.management import 开发者_StackOverflow中文版execute_manager
import imp
try:
imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)
import settings
if __name__ == "__main__":
execute_manager(settings)
Your file associations are messed up.
For some reason .py
files are associated with notepad.
They aren't associated with Python.
If you know something about windows, you can change the file associations.
if you don't know much about windows, delete and reinstall Python. This time, however, allow it to setup the file associations for you.
- Open control panel > Control panel home > Default Programs > set Associations
- Search for .py
- Select python.exe
Worked for me
On windows I right clicked on my manage.py file in the project directory and then selected open with, then chose another app, then python IDLE, then set the check mark at the bottom of the window to always use this app to open .py files and this was resolved for me. Hope it works for others as well!
I would suggest you create a new virtual environment and then reinstall python and django. That should fix the problem.
精彩评论