python - 命令“where python”在 PowerShell 中不返回任何内容
问题描述
正如标题所暗示的,当我试图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 中的版本。有人能想出如何where
在 powershell 中修复吗?
解决方案
在 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
推荐阅读
- python-3.x - 如何将重复的行数据转换为python中的列?
- wordpress - 重力形式 - 嵌套条件合并标签
- locust - 支持处理 locust 中的回调请求(服务器发起的消息)
- javascript - 子组件中的动态 router.push 路由
- python - 如何设置下拉选项的值并在 Django 中进行一些计算?
- javascript - 如何使用数据有效负载根据 if else 条件呈现对象数据?
- java - Maven & JaCoCo - 如何从依赖项引入的报告中排除一个类?
- validation - GWT 2.8.0 验证:未评估级联验证
- android - 为什么我的数组列表即使在初始化后也会抛出空指针异常?
- dataframe - 对 pyspark Dataframe 的列进行排序