タイトルで終わってるから読む必要なし
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のwhere
はWhere-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
参考
However, if you are using PowerShell, in it where is an alias of Where-Object command, so you need to use where.exe instead.