繁体   English   中英

Django - 无法运行“py manage.py runserver”

[英]Django - Cannot run "py manage.py runserver"

我试过 python manage.py runserver,结果相同。 它在终端中显示以下内容:

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases

当我运行 py --version 时,它工作正常。 我想知道为什么它说 python 没有找到,当它工作得很好时。 我没有在网上找到任何东西。

您正在检查py --version并在另一方面执行命令python manage.py runserver

试试: py manage.py runserver

并检查您的机器上是否安装了两个版本的 python。

如果 python 已正确安装(可从终端访问),您应该能够简单地键入“python”并输入 python shell。 要验证,请尝试:

2 + 2

This should output 4. If typing python does not take you to the python shell, I'm guessing you need to add python as a PATH variable.

如果您使用的是旧版本的 Django,请说 Django 3.1 及以下版本

python manage.py runserver应该可以正常工作。

我建议你坚持python而不是py

但是在 Django 的较新版本中,例如 Django 3.2 及更高版本,那么运行服务器要简单得多

只需使用: manage.py runserverpython manage.py runserver

如需进一步参考,请参阅Django 3.2 https://docs.djangoproject.com/en/tutorial/

在执行 runserver 命令之前,您需要执行activate命令

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM