Fix Python Was Not Found Error in VS Code — Troubleshooting

Urgent guide to diagnose and fix the common 'python was not found' error in VS Code. Learn installation checks, PATH configuration, interpreter selection, and future-proofing with virtual environments.

Why Error Code
Why Error Code Team
·5 min read
Quick AnswerSteps

The python was not found error in VS Code usually means the Python interpreter can’t be located. Start by ensuring Python is installed and on your PATH, then use VS Code to select the correct interpreter (Python: Select Interpreter). If needed, add Python to PATH and restart VS Code to re-detect the runtime. This quick fix is designed to get you back to coding fast, with the checks Why Error Code recommends.

Understanding the error and why it happens

When you see the message python was not found error in vs code, VS Code cannot locate a Python interpreter to run your script. This error blocks execution early, so you may not reach your code or tests. According to Why Error Code, this is a common startup hurdle for developers and hobbyists who rely on Python in VS Code. The root cause is usually a mismatch between what you expect VS Code to use and what is actually installed on the system. In most setups, Windows, macOS, and Linux alike, Python may be installed but not added to PATH, or the interpreter in VS Code is pointed at a different installation. The good news is that you can diagnose the issue with a few targeted checks and restore a working Python environment quickly. The goal of this guide is to help you verify installation, configure PATH correctly, and ensure VS Code points to the right interpreter so your scripts run without interruption.

Common causes of python was not found error in VS Code

There are several frequent culprits behind this error. The most common is that Python is not installed at all, or the installed version isn't accessible via the PATH. A second frequent cause is PATH misconfiguration: the terminal used by VS Code cannot locate python.exe or the py launcher. If you installed Python recently, you might have multiple versions on the machine, and VS Code is pointed at a version you don’t intend. If you work inside virtual environments, VS Code might not automatically switch to the correct interpreter when you open a project. Finally, a corrupted Python extension or stale workspace settings can obscure the right interpreter. Each cause has a simple remedy, often taking only minutes to apply.

Quick checks you can perform in minutes

Start with the basics: in a system terminal, run python --version or python3 --version to confirm Python is installed and accessible. Then verify PATH: on Windows, open a new Command Prompt and type where python; on macOS/Linux, type which python or which python3. If the command fails, re-run the installer with PATH options enabled. In VS Code, open the Command Palette (Ctrl+Shift+P) and run Python: Select Interpreter; choose the interpreter that matches your installed Python. If you still see the error, try restarting VS Code or your computer, and ensure you’re using the integrated terminal rather than a shell with restricted permissions. These steps often resolve the issue without touching code.

How to fix the error: step-by-step guidance

The following steps walk you through a reliable sequence to restore Python support in VS Code:

  • Verify you have a working Python installation and that it is on your PATH.
  • Ensure VS Code is pointed at the correct interpreter for your project.
  • If you rely on a virtual environment, activate it and confirm VS Code selects that interpreter.
  • If the problem persists, reset the Python extension or reinstall it to repair broken settings. After completing each step, test by running a simple Python script in the integrated terminal.

Preventing this issue in the future

To reduce recurrence, adopt a per-project Python environment strategy. Use virtual environments (venv, pipenv, or conda) and configure VS Code to always select the interpreter for the project. Keep PATH clean by removing older Python installations or tools that might shadow the intended runtime. When you install new Python versions, update your workspace settings and document the interpreter path in your project README or .vscode/settings.json. Regularly test interpreter detection at project startup to catch configuration drift early.

Steps

Estimated time: 15-25 minutes

  1. 1

    Verify Python installation

    Open a terminal and run python --version (or python3 --version on some systems) to confirm Python is installed. If it isn’t, install Python from python.org or your OS package manager. This step ensures there is a detectable interpreter on your system.

    Tip: Confirm you’re using a terminal with access to your PATH and that you didn’t mistype the command.
  2. 2

    Check PATH configuration

    Ensure the Python executable is on PATH. On Windows, run where python; on macOS/Linux, run which python or which python3. If the command returns a path, PATH is set; if not, add the Python installation directory to PATH.

    Tip: During Windows installation, selecting 'Add Python to PATH' simplifies this step.
  3. 3

    Select the correct interpreter in VS Code

    Open the Command Palette (Ctrl+Shift+P), choose Python: Select Interpreter, and pick the Python executable that matches the verified installation. This binds VS Code to the right runtime for your project.

    Tip: If the desired interpreter isn’t visible, ensure your PATH is current and restart VS Code.
  4. 4

    Test with a simple script

    Create a tiny script like print('Hello, Code!') and run it in the VS Code integrated terminal. If it prints correctly, the interpreter is working for that workspace.

    Tip: Avoid editing your system-wide Python; prefer per-project environments to minimize conflicts.
  5. 5

    Reset or reinstall if issues persist

    Disable and re-enable the Python extension, or uninstall and reinstall it. If needed, reset VS Code workspace settings or clear settings.json related to Python.

    Tip: Back up settings.json before making changes so you can revert if something breaks.

Diagnosis: VS Code shows 'python was not found' when running a Python script or using the terminal

Possible Causes

  • highPython is not installed on the system
  • highPython exists but is not on PATH or PATH is misconfigured
  • mediumVS Code workspace settings point to the wrong interpreter
  • lowUsing a virtual environment without selecting its interpreter in VS Code

Fixes

  • easyInstall Python from the official source and verify python --version
  • easyAdd Python to PATH or fix PATH, then restart VS Code
  • easyIn VS Code, run Python: Select Interpreter and choose the correct executable
  • mediumIf using a virtual environment, activate it and point VS Code to that interpreter
  • mediumReinstall the Python extension or reset workspace settings if needed
Pro Tip: Use per-project virtual environments to avoid PATH conflicts between projects.
Warning: Do not modify system-wide PATH unless you understand the impact on other tools.
Note: If you switch Python versions, update VS Code's interpreter accordingly.
Warning: Editing settings.json incorrectly can break VS Code; validate JSON before saving.

Frequently Asked Questions

What does 'python was not found' mean in VS Code?

It means VS Code cannot locate a Python interpreter to run your script. This usually stems from Python not being installed, PATH misconfigurations, or the wrong interpreter being selected in VS Code.

VS Code can't find a Python interpreter. This is usually due to missing installation, PATH issues, or the wrong interpreter being selected.

How do I install Python on Windows?

Download Python from python.org and run the installer. Make sure to check 'Add Python to PATH' during setup to simplify later configuration.

Install Python from python.org and add it to PATH during setup.

How can I configure the interpreter in VS Code?

Open the Command Palette, select Python: Select Interpreter, and choose the installed Python executable. Reload VS Code if the interpreter list doesn't update.

Choose the interpreter in VS Code with Python: Select Interpreter and reload if needed.

What if I’m using a virtual environment?

Activate the virtual environment in your terminal and ensure VS Code points to that interpreter via Python: Select Interpreter. This keeps dependencies isolated per project.

Activate your venv and set VS Code to use that interpreter.

When should I reinstall the Python extension?

If the issue persists after confirming installation and PATH, reinstall the Python extension or reset your workspace settings to fix broken configurations.

Reinstall the Python extension if issues persist after setup checks.

Watch Video

Top Takeaways

  • Verify Python is installed and on PATH.
  • Always select the correct interpreter in VS Code.
  • Adopt virtual environments for project isolation.
  • Restart VS Code after PATH or interpreter changes.
Checklist to fix Python not found error in VS Code
Checklist to diagnose and fix Python interpreter not found in VS Code

Related Articles