How to Find Python Path in Windows: A Step-by-Step Guide

The ‘Python path’ can mean the python.exe location, the directories Python searches for modules, or the Windows PATH environment variable. Check the one you actually need.

Steps

  1. Open Command Prompt or PowerShell.
  2. Run where python and where py in Command Prompt, or Get-Command python in PowerShell, to see which executable resolves.
  3. Run python -c “import sys; print(sys.executable)” to display the interpreter used by that command.
  4. Run python -c “import sys; print(*sys.path, sep=’\n’)” when you need the module-search paths.
  5. If using a virtual environment, activate it first and repeat the commands because its interpreter path should differ.

How it works

The Microsoft Store app execution alias can make ‘python’ behave differently on a machine without a normal Python installation. The Python Launcher (py) can select among installed versions. IDEs can also use an interpreter different from the shell.

Important considerations

Do not globally edit PATH merely to fix one virtual environment. Prefer the official Python installer/launcher and project-specific environments.

Practical guidance

If several Python installations appear, do not delete one until you know which applications use it. `py -0p` can list interpreters recognized by the Python Launcher on supported installations. In VS Code or another IDE, inspect the selected interpreter because it can override what `python` resolves to in a normal terminal.

Setting up a dev PC? Read how to install Git on Windows 11.

Not installed yet? See how to install Python on Windows 11.

See also adding Python to PATH.

More detail

`sys.path` is built from the interpreter, environment, installed packages, current working context, and configuration; it should not usually be edited by hand. Install project dependencies into a virtual environment with that environment’s Python/pip. `python -m pip` helps ensure pip belongs to the interpreter you intend.