which command
A shell command that shows which program a command name will run, by searching PATH the same way the shell does.
In more detail
which -a python3 lists every match in PATH order on macOS and Linux; the first one wins. On Windows, where python does the same job in Command Prompt and Get-Command python in PowerShell. It is the quickest way to see why an old or unexpected Python answers.
Example
which -a python3Related terms
- PATH — An environment variable holding a list of folders the shell searches, in order, to find the program for a command you type.
- sys.executable — The full path of the Python interpreter file that is running the current program.
Taught in
- Installing Python On Windows — Hands-on Python: Complete Video Course & Book
- Installing Python On A Mac — Hands-on Python: Complete Video Course & Book
- Installing Python On Linux — Hands-on Python: Complete Video Course & Book
- Where Python Lives: PATH And Versions — Hands-on Python: Complete Video Course & Book