[英]'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.