Run where python in Command Prompt (where.exe python in PowerShell), execute py -0p to list every registered Python installation path on your system, or print sys.executable inside Python to see the exact python.exe path currently running.
Basic Example
:: 1. Windows Command Prompt (cmd.exe): Show all python.exe binaries on PATH in priority order
where python
:: 2. List ALL registered Python installations and their exact paths via the Windows Python Launcher
py -0p
# 3. Windows PowerShell (use where.exe because `where` is aliased to Where-Object in PowerShell)
where.exe python
(Get-Command python).Source
# 4. Inside any Python script or REPL: Print the active interpreter's exact executable path
import os
import sys
print(sys.executable) # e.g., C:\Users\Alice\AppData\Local\Programs\Python\Python312\python.exe
print(os.path.dirname(sys.executable)) # Installation root directory
Key Details & Edge Cases
- Microsoft Store alias stub (
WindowsApps\python.exe) trap:- On Windows 10/11, running
where pythonoften returnsC:\Users\<user>\AppData\Local\Microsoft\WindowsApps\python.exefirst. That file is a 0-byte Windows App Execution Alias stub that opens the Microsoft Store if no real Python precedes it inPATH(or points to a sandboxed Store install). - Check
py -0p(which queries the Windows Registry via PEP 514 and lists real installations with an*next to the default) or look past theWindowsAppsentry inwhere pythonoutput.
- On Windows 10/11, running
- PowerShell
wherealias difference:- In Windows PowerShell,
whereis a built-in alias forWhere-Object, so typingwhere pythonprompts for filter parameters instead of searchingPATH. Always typewhere.exe pythonor(-Command python).Sourcein PowerShell.
- In Windows PowerShell,
- Active virtual environment vs. base system Python (
sys.executablevs.sys.base_executable):- When a virtual environment (
.venv) is active,sys.executablereturns.venv\Scripts\python.exe. - To find the underlying base Python installation that created the virtual environment without deactivating it, inspect
sys.base_executableorsys.base_prefix:import sys print("Active interpreter:", sys.executable) print("Base installation: ", sys.base_executable)
- When a virtual environment (
- Default Windows installation directories by installer type:
- Per-user official python.org installer:
C:\Users\<User>\AppData\Local\Programs\Python\Python3XX\python.exe - System-wide (“Install for all users”) installer:
C:\Program Files\Python3XX\python.exe - Miniconda / Anaconda:
C:\Users\<User>\miniconda3\python.exeorC:\ProgramData\anaconda3\python.exe - uv-managed Python:
C:\Users\<User>\AppData\Roaming\uv\python\cpython-3.XX...\python.exe
- Per-user official python.org installer:
Comparison of Windows Python Path Lookup Methods
| Method | Environment | Lists Multiple Versions? | Shows Active Virtual Env? | Best Used When |
|---|---|---|---|---|
py -0p |
cmd / PowerShell |
Yes (all registry-registered installs) | No (shows global/user installs) | Discovering every Python version installed on a Windows machine and which one is default (*). |
where python / where.exe python |
cmd / PowerShell |
Yes (all matches in PATH order) |
Yes (lists .venv\Scripts\python.exe first) |
Checking which python.exe runs when you type python and spotting WindowsApps stub conflicts. |
sys.executable |
Python code / REPL | No (current interpreter only) | Yes | Programmatically getting the exact python.exe executing your script. |
sys.base_executable |
Python code / REPL | No (base interpreter only) | Resolves through venv to base | Finding the parent system Python path while inside an active .venv. |
You must log in or register to comment.
