正如标题所暗示的那样,当我试图从where python
从PowerShell获得任何信息时,它什么也不返回。没有错误什么的..。它只是转到一个新行(好像我按了"Enter")
另一方面,CMD提示符成功地返回以下内容:
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
吗?
发布于 2021-05-25 18:09:28
在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
https://stackoverflow.com/questions/67693360
复制相似问题