Python Fix

Windows Runs the Wrong Python Version? Here’s How to Fix It

If python --version shows an older or unexpected version, Windows is resolving a different interpreter than the one you intended to use.

Difficulty: Medium Time: 15–35 minutes Updated: July 2026 Works for: Windows 10 / Windows 11

Multiple Python versions are normal. The problem begins when terminals, VS Code, pip, and file associations select different ones. That can produce missing-package errors, incompatible syntax, or scripts that behave differently depending on how they are launched.

Do not uninstall versions blindly. First map every command to its actual executable, then decide which version should be the system default and which should remain project-specific.

Identify every Python Windows can see

where python
where py
py -0p
python -c "import sys; print(sys.version); print(sys.executable)"

where python may return several paths. Windows normally launches the first one. py -0p shows versions registered with the Python Launcher.

Fix 1 — Put the intended version first in PATH

  1. Open Edit environment variables for your account.
  2. Edit the User Path.
  3. Move the desired Python folder and Scripts folder above older Python entries.
  4. Remove only paths that point to versions you no longer use or folders that no longer exist.
  5. Open a new terminal and test again.

Fix 2 — Check User PATH and System PATH separately

A system-wide Python entry can override expectations, especially on shared computers or machines configured by development tools. Compare both lists. A user-level entry is usually safer for a personal installation because it does not affect other accounts.

Fix 3 — Use the Python Launcher for explicit versions

py -3.12 script.py
py -3.11 -m venv .venv
py -3.12 -m pip install requests

Version-specific launcher commands are the cleanest way to create environments and install packages when several interpreters must remain installed.

Fix 4 — Recreate virtual environments made with an old version

A virtual environment stores a reference to the interpreter used when it was created. Changing the global PATH does not upgrade an existing environment.

py -3.12 -m venv .venv
.venv\Scripts\activate
python --version

Before deleting an old environment, save its dependencies if needed:

python -m pip freeze > requirements.txt

Fix 5 — Align VS Code with the project interpreter

  1. Open the project folder.
  2. Run Python: Select Interpreter.
  3. Choose the intended virtual environment or Python version.
  4. Open a new integrated terminal.
  5. Run python -c "import sys; print(sys.executable)".

The status bar, terminal, debugger, and Pylance should all point to the same environment.

Fix 6 — Check file associations for double-clicked scripts

Double-clicking a .py file may use a different registered interpreter than Command Prompt. Right-click a script, choose Open with, and verify the selected Python application. For reliable development, run scripts from a terminal or IDE instead of relying on file associations.

Fix 7 — Make pip target the intended version

python -m pip --version
py -3.12 -m pip --version

The output includes the package directory and Python version. Install with the interpreter-qualified form rather than assuming the standalone pip command is correct.

Removing an older Python version can break projects, scheduled tasks, or applications that depend on it. Verify usage before uninstalling.

FAQ

Why does Command Prompt show one version and VS Code another?

VS Code can select an interpreter directly from workspace settings, independent of the terminal’s default PATH.

Can multiple Python versions share packages?

Not automatically. Each interpreter and virtual environment has its own package location.

Should I change the default version globally?

Only when most projects use it. Project-specific virtual environments are safer than constantly changing the global default.