正如标题所暗示的,当我尝试where python
从PowerShell 时,它没有返回任何内容。没有错误或其他什么...它只是换行(就像我按“Enter”一样)
另一方面,CMD Prompt 成功返回以下内容:
C:\Users\User>where python
C:\Users\User\AppData\Local\Programs\Python\Python38\python.exe
C:\Users\user\AppData\Local\Microsoft\WindowsApps\python.exe
python --version
成功返回 pwsh 和 cmd 中的版本。有人能想出如何修复 powershell 中的 where
吗?
在 PowerShell 中,where
是 Where-Object
cmdlet 的别名。
要显式调用 where.exe
,请包含 .exe
扩展名:
PS ~> where.exe python
C:\Users\mathias\AppData\Local\Microsoft\WindowsApps\python.exe
如果您想弄清楚为什么某个命令名称没有按预期解析,请使用 Get-Command
:
PS ~> Get-Command where
CommandType Name Version Source
----------- ---- ------- ------
Alias where -> Where-Object
PS ~> Get-Command where*
CommandType Name Version Source
----------- ---- ------- ------
Alias where -> Where-Object
Cmdlet Where-Object 3.0.0.0 Microsoft.PowerShell.Core
Application where.exe 10.0.19041.1 C:\WINDOWS\system32\where.exe
作为一个有趣的奖励,您对 Get-Command
的新知识可能会证明 where.exe
已过时 - 因为 Get-Command
显然具有定位可执行文件的能力:)
PS ~> Get-Command python
CommandType Name Version Source
----------- ---- ------- ------
Application python.exe 0.0.0.0 C:\Users\mail\AppData\Local\Microsoft\WindowsApps\python.exe