5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PowerShellでコマンドのパスを確認したいときはwhereに.exeをつけること

Last updated at Posted at 2023-12-16

タイトルで終わってるから読む必要なし

PS C:\> where.exe python
C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\python.exe
C:\Users\xxxxx\AppData\Local\Microsoft\WindowsApps\python.exe

linuxではwhichで確認できる

$ which python3
/usr/bin/python3

windowsでは(紛らわしいことに)whereを使う
が、存在するはずのpythonのパスが表示されない...

PS C:\> where python
PS C:\> python --version
Python 3.12.0

コマンドプロンプトではwhereで表示できる

c:\>where python
C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\python.exe
C:\Users\xxxxx\AppData\Local\Microsoft\WindowsApps\python.exe

PowerShellではwhere.exeにしないといけないらしい

PS C:\> where.exe python
C:\Users\xxxxx\AppData\Local\Programs\Python\Python312\python.exe
C:\Users\xxxxx\AppData\Local\Microsoft\WindowsApps\python.exe

なんでかというと、PowerShellのwhereWhere-Objectのエイリアスだからなんだと
もうマヂ無理。。。

code $profileしてエイリアス足しとこ

Set-Alias which where.exe

追記

Get-Commandでもいい

PS C:\> get-command python

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     python.exe                                         3.12.150.… C:\Users\inarb\AppData\Local\Programs\Py…
PS C:\> (get-command python).Source
C:\Users\inarb\AppData\Local\Programs\Python\Python312\python.exe

where.exeのほうは複数渡せる

PS C:\> where.exe flutter dart
C:\flutter\bin\flutter
C:\flutter\bin\flutter.bat
C:\flutter\bin\dart
C:\flutter\bin\dart.bat

参考

Windows install | Flutter

However, if you are using PowerShell, in it where is an alias of Where-Object command, so you need to use where.exe instead.

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?