【发布时间】:2018-05-28 02:18:26
【问题描述】:
我已在我的 Windows 10 PC 中安装了 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 时,我都需要输入上面的代码。这有点烦人。任何帮助,将不胜感激。谢谢。
【问题讨论】:
-
@JohnGordon 谢谢!但我不明白给出的答案。能给个简单的答案吗?? ;-)
标签: python windows powershell