简体   繁体   English

'django' 在 PyCharm 的虚拟环境中未被识别为内部或外部命令

[英]'django' is not recognized as an internal or external command in PyCharm's virtual environment

New to PyCharm and Django, I've looked through online for this solution for a few hours already, nothing seems to work. PyCharm 和 Django 的新手,我已经在网上浏览了这个解决方案几个小时,似乎没有任何效果。

The usual: python -m django-admin startproject mysite does not seem to work if my cmd directory is at C:\Users\...\PycharmProjects\ The usual: python -m django-admin startproject mysite does not seem to work if my cmd directory is at C:\Users\...\PycharmProjects\

On the other hand, if I use cd C:\Users\...\AppData\Local\Programs\Python\Python38\Scripts before reentering the former code, I get the exact results that I want.另一方面,如果我在重新输入以前的代码之前使用cd C:\Users\...\AppData\Local\Programs\Python\Python38\Scripts ,我会得到我想要的确切结果。

Any idea how to fix this?知道如何解决这个问题吗?

Edit: Okay, so I figured a solution.编辑:好的,所以我想出了一个解决方案。 If I were to copy "django-admin.exe" into C:\Users\...\PycharmProjects\ , django-admin startproject mysite will work as intended.如果我将“django-admin.exe”复制到C:\Users\...\PycharmProjects\django-admin startproject mysite将按预期工作。

The real issue I have is the command python -m itself.我遇到的真正问题是命令python -m本身。 Nothing that follows after that line seems to work with it.该行之后的任何内容似乎都无法使用。 I've revised my advanced environment pathing, but so far I haven't had much luck.我已经修改了我的高级环境路径,但到目前为止我还没有多少运气。

Edit 2: Typing python takes me to Windows Store, but py will work as intended.编辑 2:键入python将我带到 Windows 商店,但py将按预期工作。 Subsequently, problems like py -m django --version will work as intended if I type them in cmd.随后,如果我在 cmd 中键入类似py -m django --version的问题,它们将按预期工作。 However, the problem persist if I try to do it in my PyCharm virtual environment.但是,如果我尝试在我的 PyCharm 虚拟环境中执行此操作,问题仍然存在。

I've tested and changed multiple directories for both cmd and PyCharm's virtual environment, the solution works consistently in cmd, but not in Pycharm.我已经为 cmd 和 PyCharm 的虚拟环境测试并更改了多个目录,该解决方案在 cmd 中始终有效,但在 Pycharm 中无效。 Any explanations for this?对此有何解释?

You have to add python to your system path variable this is a quick tutorial on how to do so您必须将 python 添加到系统路径变量中,这是有关如何执行此操作的快速教程

暂无
暂无

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

相关问题 虚拟环境在 vscode 中不被识别为内部或外部命令 - Virtual environment is not recognized as an internal or external command in vscode Windows上的PyCharm:无法将“ django-admin”识别为内部或外部命令 - PyCharm on Windows: 'django-admin' is not recognized as an internal or external command 'django' 未被识别为内部或外部命令, - 'django' is not recognized as an internal or external command, pipenv shell 在虚拟环境中启动子shell…“powershell.exe”不是内部或外部命令,也不是可运行的程序或 - pipenv shell Launching subshell in virtual environment… 'powershell.exe' is not recognized as an internal or external command, operable program or 在 PySide2 虚拟环境中调用 lrelease 时如何修复“无法识别为内部或外部命令”? - How to fix “Not Recognized As an Internal or External Command” when calling lrelease in PySide2 virtual environment? 如何修复错误“'django-admin'不被识别为内部或外部命令”? - How to fix error “'django-admin' is not recognized as an internal or external command”? WGET 不被识别为内部或外部命令 - WGET is not recognized as an internal or external command 'PyJWT' 未被识别为内部或外部命令 - 'PyJWT' is not recognized as an internal or external command '机器人未被识别为内部或外部命令' - 'robot is not recognized as an internal or external command' 'heroku' 不被识别为内部或外部命令 - 'heroku' is not recognized as an internal or external command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM