命令在vscode Powershell终端中不起作用

时间:2019-12-25 02:14:23

标签: python-3.x powershell visual-studio-code

当我尝试在vscode的终端中执行任何命令时,出现类似的错误。有人知道如何解决这个问题吗?

pip : The term 'pip' 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
+ pip install nba_api
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pip:String) [], CommandNotF  
   oundException
    + FullyQualifiedErrorId : CommandNotFoundException

1 个答案:

答案 0 :(得分:0)

您必须将pip路径包括到PATH环境变量中。 Powershell或Cmd无法自动理解路径。如果不在PATH环境变量中注册目录,则必须包含pip命令的完整路径。所以你必须使用这个:

cmd /c "setx.exe PATH %PATH%;ThePathOfPip"

运行此命令后,关闭所有powershell实例,并在下一次会话后进行更改。

这也将起作用:

$env:path = $env:path + ";" + "The path of pip"

但是它只会保存当前会话的值,因此我不建议这样做。

使用提供的评论链接中的一点并结合我自己的知识来写出这个答案。