python
cmd
windows store
command prompt issue
windows troubleshooting

CMD opens Windows Store when I type 'python'

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

When you type python in Windows CMD and it opens the Microsoft Store instead of running Python, it means Windows is executing an "app execution alias" — a stub that redirects to the Store to install Python. This happens because Windows 10/11 ships with placeholder python.exe and python3.exe aliases that take priority over your actual Python installation in the PATH. The fix is to disable these aliases in Windows Settings or ensure your Python installation's directory appears before the alias directory in PATH.

Why This Happens

Windows 10 (version 1903+) and Windows 11 include app execution aliases for python.exe and python3.exe in %LOCALAPPDATA%\Microsoft\WindowsApps. These are zero-byte stub executables that redirect to the Microsoft Store when run:

 
C:\Users\you\AppData\Local\Microsoft\WindowsApps\python.exeStore stub
C:\Python311\python.exeReal Python

If WindowsApps appears before your Python directory in PATH, the stub runs first.

  1. Open Settings (Win + I)
  2. Go to AppsAdvanced app settingsApp execution aliases
    • On older Windows 10: AppsApps & featuresApp execution aliases
  3. Turn OFF both python.exe and python3.exe aliases
 
App installer - python.exeOFF
App installer - python3.exeOFF

After disabling, CMD uses the real python.exe from your PATH.

Fix 2: Reorder PATH

Ensure your Python directory appears before WindowsApps in PATH:

bash
1# Check current Python location
2where python
3# C:\Users\you\AppData\Local\Microsoft\WindowsApps\python.exe  ← stub
4# C:\Python311\python.exe                                        ← real
5
6# The stub appears first because WindowsApps is earlier in PATH

To fix:

  1. Open System PropertiesEnvironment Variables
  2. Under User variables or System variables, select Path and click Edit
  3. Move your Python directory (C:\Python311\ and C:\Python311\Scripts\) above %LOCALAPPDATA%\Microsoft\WindowsApps
  4. Click OK and restart CMD

Or from the command line:

cmd
:: Temporarily add Python to the front of PATH
set PATH=C:\Python311;C:\Python311\Scripts;%PATH%
python --version

Fix 3: Use the Python Installer's PATH Option

When installing Python from python.org:

  1. Run the Python installer
  2. Check "Add Python to PATH" on the first screen
  3. Click Customize installation → check "Add Python to environment variables"
  4. The installer places your Python directory before WindowsApps in PATH

If you already installed without this option:

cmd
:: Add Python to PATH permanently via setx
setx PATH "C:\Python311;C:\Python311\Scripts;%PATH%"

Fix 4: Use the Full Path

As a workaround, call Python using its full path:

cmd
1C:\Python311\python.exe --version
2
3:: Or use 'py' launcher (installed with Python from python.org)
4py --version
5py -3.11 script.py

The py launcher (py.exe) is installed in C:\Windows\ and is not affected by the app execution alias issue.

Verifying the Fix

cmd
1:: Check which python runs
2where python
3:: Should show: C:\Python311\python.exe (not WindowsApps)
4
5:: Verify it works
6python --version
7:: Python 3.11.x
8
9:: Check pip too
10pip --version
11:: pip 23.x from C:\Python311\Lib\site-packages\pip

PowerShell Differences

PowerShell has the same issue but also has its own alias system:

powershell
1# Check what 'python' resolves to
2Get-Command python
3# If it shows WindowsApps, the same fix applies
4
5# PowerShell may also have an alias
6Get-Alias python  # Check for PowerShell aliases
7
8# Force the correct executable
9& "C:\Python311\python.exe" --version

Common Pitfalls

  • Disabling aliases but not restarting CMD: After changing app execution aliases or PATH, existing CMD windows still use the old PATH. Close all CMD windows and open a new one for changes to take effect.
  • Using setx and expecting immediate effect: setx modifies the registry but does not update the current session's PATH. After setx, open a new CMD window. Or use set for the current session and setx for persistence.
  • Virtual environment activation not finding Python: If the base Python is the Store stub, creating a virtual environment fails. Fix the PATH first, then create your virtualenv.
  • Multiple Python versions with conflicting PATH entries: If both Python 3.9 and 3.11 are installed, their PATH entries may conflict. Use the py launcher (py -3.11, py -3.9) to select a specific version without PATH ordering issues.
  • Assuming the fix works for all terminals: Windows Terminal, Git Bash, WSL, and VS Code each have their own PATH handling. Disabling the alias fixes CMD and PowerShell, but other terminals may need separate configuration.

Summary

  • Windows 10/11 ships stub python.exe aliases that redirect to the Microsoft Store
  • Disable them in Settings → Apps → App execution aliases
  • Alternatively, reorder PATH so your Python directory comes before WindowsApps
  • Use the py launcher (py.exe) to avoid PATH issues entirely
  • Always restart CMD after changing PATH or alias settings
  • Check with where python to verify which executable runs

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions