Why Does VS Code Show “Python Not Found” in the Terminal?

Fix "Python not found" errors in VS Code by ensuring Python is installed, correctly added to the system PATH, and selected as the right interpreter.

Introduction

If you see the error "Python not found" in VS Code’s terminal, it means that Python is either not installed or not correctly added to the system PATH. This guide will help you troubleshoot and fix the issue.


Step 1: Check If Python Is Installed

  • Open a terminal outside VS Code (Command Prompt or Terminal) and run:
  • python --version (Windows/macOS/Linux)
  • python3 --version (macOS/Linux if Python 3 is required)
  • If Python is not installed, download and install it from python.org.

Step 2: Verify Python Is Added to PATH (Windows)

  • Open Command Prompt and run: where python
  • If no output appears, Python is not in the system PATH.
  • To add Python to PATH manually:
    1. Open the Start menu and search for "Edit the system environment variables."
    2. Click "Environment Variables."
    3. In "System Variables," find "Path" and click "Edit."
    4. Click "New" and add the path to your Python installation
       (e.g., C:\Users\YourUser\AppData\Local\Programs\Python\Python39\).
    5. Click "OK" and restart your terminal.

Step 3: Verify Python Is Recognized in VS Code

  • Restart VS Code after adding Python to PATH.
  • Open a new terminal in VS Code (Ctrl + `).
  • Run python --version to check if Python is now recognized.

Step 4: Select the Correct Python Interpreter in VS Code

  • Press Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (macOS).
  • Type “Python: Select Interpreter” and press Enter.
  • Select the correct Python installation from the list.

Step 5: Use the Full Path to Python

  • If Python still isn’t recognized, try running it with the full path:
    C:\Users\YourUser\AppData\Local\Programs\Python\Python39\python.exe script.py
  • On macOS/Linux, use: /usr/bin/python3 script.py

Final Thoughts

If VS Code is showing "Python not found", the issue is often related to Python not being installed, not being in the system PATH, or the wrong interpreter being selected. Following these steps should resolve the issue.

Next Step: Learn how to fix indentation errors in Python in our next guide: How Do I Fix Indentation Errors in Python?

Share the Post:

Related Posts