用 where.exe 定位 Windows 中的可执行文件
列出命令名在 PATH 中的所有匹配——“到底运行的是哪个 python?”的最快答案。
运行 `where.exe python`(PowerShell 里必须带 .exe 后缀),按执行优先级列出 PATH 上所有 python。
01命令
命令
$ where.exe python02作用说明
where.exe 会依次搜索当前目录和每个 PATH 条目并打印所有匹配,第一行就是真正会被执行的那个。在 PowerShell 中 `where` 是 Where-Object 的别名,所以必须完整输入 where.exe——这是经典坑。它还能做简单的文件模式搜索(`where.exe /r C:\Projects *.sln`),但排查 PATH 问题时记住基本用法即可,配合 `$env:Path -split ';'` 可以看到原始搜索顺序。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- where | Microsoft Learn依据: Microsoft documents where.exe as displaying the location of files matching a search pattern, searching the current directory and PATH.
- WHERE - Windows CMD依据: SS64 explains where.exe searches PATH for executables and how it differs from PowerShell's Where-Object alias.
最后验证: 2026-09-17 · 分类: 开发者