You may see a message such as “Python was not found; run without arguments to install from the Microsoft Store” when Windows cannot locate a working Python installation. The cause is usually a missing installation, incorrect PATH, an app-execution alias, or the wrong interpreter in VS Code.
py --version. If it works, use
py temporarily and repair the python command by disabling the
Windows App Installer aliases or correcting PATH. If neither command works, install
Python from Python.org and reopen every terminal.
Choose the correct fix from your test result
| What happens | Most likely cause | Start here |
|---|---|---|
py works, but python fails |
PATH or Windows app-execution alias | Fix 2, then Fix 3 |
Both py and python fail |
Python is missing or the installation is incomplete | Fix 1 |
| Python works in Command Prompt but not VS Code | Wrong interpreter or stale VS Code terminal | Fix 4 |
Microsoft Store opens when you type python |
App Installer alias is taking priority | Fix 2 |
Diagnose the “Python was not found” error first
Open a new Command Prompt or PowerShell window and run these commands:
python --version
py --version
where python
where py
If py works but python does not, Python is installed but the
main command is missing from PATH or intercepted by a Windows alias. If
where python points to Microsoft\WindowsApps, go directly to Fix 2.
Fix 1 — Install Python correctly
- Download Python from Python.org for Windows.
- Open the current Python Install Manager or the full Windows installer you downloaded.
- With the classic installer, tick Add python.exe to PATH before choosing Install Now.
- With the current Install Manager, finish setup and install the recommended stable runtime.
- Restart Command Prompt and VS Code.
- Run
python --versionandpy --versionagain.
Fix 2 — Disable Windows app execution aliases
- Open Settings → Apps → Advanced app settings → App execution aliases.
- If that path is different on your Windows build, search Settings for App execution aliases.
- Find the entries for python.exe and python3.exe.
- Turn off the Microsoft Store aliases.
- Close and reopen Command Prompt.
These aliases can redirect the Python command to the Microsoft Store instead of your actual Python installation. After switching them off, close all existing terminals and open a new one before testing again.
Fix 3 — Add Python to PATH manually
First locate your Python folder. Common locations include:
C:\Users\YOUR-NAME\AppData\Local\Programs\Python\Python3xx\
C:\Program Files\Python3xx\
Add both the Python folder and its Scripts folder to PATH:
C:\Users\YOUR-NAME\AppData\Local\Programs\Python\Python3xx\
C:\Users\YOUR-NAME\AppData\Local\Programs\Python\Python3xx\Scripts\
- Search Windows for Environment Variables.
- Open Edit the system environment variables.
- Click Environment Variables.
- Select Path under your user variables.
- Click Edit → New.
- Add the Python and Scripts paths.
- Click OK and restart the terminal.
...\python.exe filename. Do not delete unrelated PATH entries.
Confirm Windows now resolves the intended executable:
where python
python --version
python -c "import sys; print(sys.executable)"
Fix 4 — Select the correct interpreter in VS Code
- Open your project in VS Code.
- Press Ctrl + Shift + P.
- Search for Python: Select Interpreter.
- Choose the Python installation or virtual environment used by the project.
- Open a new terminal inside VS Code.
Then test:
python --version
python -m pip --version
If the environment is missing from the list, run
Python Environments: Refresh All Environment Managers from the Command
Palette. You can also choose Enter interpreter path and select the correct
python.exe. The selected environment controls running, debugging, and Python
language features in the workspace.
Fix 5 — Install the VS Code Python extension
- Open Extensions in VS Code.
- Search for Python.
- Install the official extension published by Microsoft.
- Reload VS Code.
- Select your interpreter again.
Fix 6 — Repair a virtual environment
A moved, deleted, or broken virtual environment can point VS Code to a Python executable that no longer exists. Recreate it from the project folder:
py -m venv .venv
Activate it:
.venv\Scripts\activate
Then reinstall the project packages:
python -m pip install -r requirements.txt
Fix 7 — Use the Python launcher
On Windows, the Python launcher often works even when the python command does not.
py your-script.py
py -m pip install package-name
To see the Python versions detected by the launcher, run:
py --list
If Python was working before but suddenly stopped
- Run
where pythonto check whether WindowsApps now appears before your real Python folder. - Recheck the app-execution aliases because a Windows update may have changed them.
- Open Installed apps, select Python, and use Modify or Repair when available.
- Remove only stale Python PATH entries that point to folders that no longer exist.
- Restart Windows if newly opened terminals still inherit the old PATH.
Common mistakes
- Installing Python but leaving VS Code open during installation
- Adding only the Scripts folder and not the main Python folder
- Selecting a deleted virtual environment
- Installing packages with one Python version and running another
- Using
pipdirectly whenpython -m pipis safer
FAQ
Why does “py” work but “python” does not?
The Python launcher is installed, but the Python executable is not available through PATH or is being overridden by a Windows alias.
Why does Python work in Command Prompt but not VS Code?
VS Code may be using a different interpreter or an old terminal session. Select the correct interpreter and open a fresh terminal.
Should I reinstall Python?
Reinstallation is often the quickest solution when the installation is incomplete or PATH settings are badly broken.
Why does typing Python open the Microsoft Store?
Windows is resolving an App Installer alias instead of your installed Python executable.
Disable the python.exe and python3.exe aliases, reopen the terminal,
and verify the result with where python.
Do I add python.exe itself to PATH?
No. Add the folder that contains python.exe and, when needed, its
Scripts folder. PATH entries should be directories rather than the executable file.