我试着寻找为什么这种情况会持续发生,因为我想我已经看到其他人提到了这个问题。在
每当我从命令行运行manage.py runserver
时,它只打开管理.py记事本中项目目录中的文件。如果我在命令的开头包含python,它会说'python' is not recognized as an internal or external command, operable program or batch file.
我现在用的是windows。我以前在运行linux,它运行得很好…我只是把我正在处理的所有文件转移到windows上,然后这个问题就开始发生了。在
重申一下,当我运行runserver命令时发生的唯一情况是管理.py文件在记事本中打开,其中包含以下内容:
#!/usr/bin/env python
from django.core.management import 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)
你的文件关联搞砸了。在
由于某些原因,
.py
文件与记事本相关联。在它们与Python没有关联。在
如果您了解windows,可以更改文件关联。在
如果您不太了解windows,请删除并重新安装Python。不过,这次允许它为您设置文件关联。在
为我工作
在windows上,我右键单击管理.py文件在项目目录中,然后选择“打开方式”,然后选择另一个应用程序,然后选择python IDLE,然后在窗口底部设置复选标记以始终使用此应用程序打开.py文件,这一问题已为我解决。希望对其他人也有用!在
相关问题 更多 >
编程相关推荐