首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >命令"where python“不返回PowerShell中的任何内容

命令"where python“不返回PowerShell中的任何内容
EN

Stack Overflow用户
提问于 2021-05-25 18:04:37
回答 1查看 1.4K关注 0票数 3

正如标题所暗示的那样,当我试图从where python 从PowerShell获得任何信息时,它什么也不返回。没有错误什么的..。它只是转到一个新行(好像我按了"Enter")

另一方面,CMD提示符成功地返回以下内容:

代码语言:javascript
运行
复制
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吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-25 18:09:28

在PowerShell中,whereWhere-Object cmdlet的别名。

要显式调用where.exe,包括.exe扩展:

代码语言:javascript
运行
复制
PS ~> where.exe python
C:\Users\mathias\AppData\Local\Microsoft\WindowsApps\python.exe

如果您想知道为什么某个命令名不按预期解析,请使用Get-Command

代码语言:javascript
运行
复制
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显然也有能力定位可执行文件:)

代码语言:javascript
运行
复制
PS ~> Get-Command python
    
CommandType Name       Version Source
----------- ----       ------- ------
Application python.exe 0.0.0.0 C:\Users\mail\AppData\Local\Microsoft\WindowsApps\python.exe
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67693360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档