pip Is Not Found. How do I Fix It?

Fix the error when pip is not found in VS Code. Learn how to check installation, add pip to PATH, and use Python’s module invocation for package management.

Introduction

If you see the error 'pip' is not recognized as an internal or external command or command not found: pip, it means Python’s package manager pip is either missing or not properly set up. This guide will help you resolve the issue.


Step 1: Check If pip Is Installed

  • Run the following command in a terminal to check if pip is installed: pip --version
  • If the command returns a version number (e.g., pip 23.0.1), pip is installed correctly.
  • If you see an error like "command not found" or "pip is not recognized", proceed to the next step.

Step 2: Ensure Python and pip Are Installed Correctly

  • Run the following command to check if Python includes pip:
    python -m ensurepip --default-pip
  • If pip is still missing, manually reinstall it with:
    python -m pip install --upgrade pip

Step 3: Add pip to the System PATH

If pip is installed but not found, add it to the system PATH.

Windows

  • Open Command Prompt and check Python’s install location: where python
  • Find the Scripts directory, usually located at:
    C:\Users\YourUser\AppData\Local\Programs\Python\Python39\Scripts
  • Manually add this path to the system PATH:
    setx PATH "%PATH%;C:\Users\YourUser\AppData\Local\Programs\Python\Python39\Scripts"

macOS/Linux

  • Find the pip installation path: which pip
  • If pip is installed but not found, add it to the PATH: export PATH="$HOME/.local/bin:$PATH"
  • To make the change permanent, add the above line to ~/.bashrc or ~/.zshrc.

Step 4: Use Python Instead of pip

  • If pip still does not work, try running:
    python -m pip install package_name
  • Example: python -m pip install requests
  • This ensures that pip runs using the correct Python interpreter.

Final Thoughts

Fixing pip-related errors often involves re-installing pip, adding it to the system PATH, or using Python’s module invocation. Following these steps will ensure pip works correctly in your VS Code setup.

🔹 Next Step: Learn how to fix issues when a Python script doesn’t run in VS Code: Why Is My Python Script Not Running in VS Code?

Share the Post:

Related Posts