我已经在我的Windows 10电脑上安装了Python 3.6版本。同时我使用Pycharm编写我的脚本,它可以正常运行。但我的问题是我无法在PowerShell中运行Python。我被告知只需在PowerShell中键入“python”即可自动启动Python。但是,我收到了一个错误提示,说它无法识别。
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\lenovo> python
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
有些人建议输入以下内容:
[Environment]::SetEnvironmentVariable("Path", "$enc:Path;C:\Users\lenovo\AppData\Local\Programs\Python\Python36")
上述代码中给出的路径对我的电脑来说是正确的。实际上,在我输入上述代码后,Python可以运行。但这是我的问题。每次我关闭并重新打开PowerShell时,我都必须输入上述代码才能让Python运行。我尝试在以管理员身份运行的PowerShell中键入此命令,但它不起作用。我甚至尝试重新启动电脑,但问题仍然无法解决。
每次我想在新的PowerShell窗口中运行Python时,都需要输入上述代码,这有点烦人。任何帮助都将不胜感激。谢谢。