How do you fix the "'pip' is not recognized as an internal or external command" error? | A1Lab@MZeeshanM to PythonEnglish •
edit-2
7 days ago

How do you fix the "'pip' is not recognized as an internal or external command" error?

message-square
0

Run py -m pip <command> (or python -m pip <command>) as an immediate workaround, and fix the error permanently on Windows by either bootstrapping pip with ensurepip or adding Python’s Scripts directory to your Windows PATH environment variable.

1. Immediate Workaround (No PATH Changes Required)

Instead of calling bare pip, invoke pip as a module directly through the Python launcher (py on Windows) or your active python executable:

# Windows (recommended — uses the official Python launcher)
py -m pip install <package_name>

# Cross-platform / inside an activated virtual environment
python -m pip install <package_name>

2. Permanent Fix Step-by-Step (Windows)

Step A: Ensure pip is actually installed

If running py -m pip --version says No module named pip, bootstrap it using Python’s built-in ensurepip module:

py -m ensurepip --upgrade
py -m pip install --upgrade pip

Step B: Add Python’s Scripts folder to Windows PATH

If py -m pip --version works, pip.exe is installed on your machine—Windows simply doesn’t know where to find it.

  1. Print the exact path to your Python Scripts folder in Command Prompt or PowerShell:

    py -c "import sys, os; print(os.path.join(sys.prefix, 'Scripts'))"
    

    (Typical output: C:\Users\<YourName>\AppData\Local\Programs\Python\Python312\Scripts)

  2. Open the Windows Start Menu, search for “Edit environment variables for your account”, and press Enter.

  3. Under User variables, select Path and click Edit.

  4. Click New, paste the exact Scripts folder path printed in Step 1 (and add the parent Python312 folder if it isn’t listed yet), then click OK on all dialogs.

  5. Close and reopen your terminal window so it reloads the updated PATH, then verify:

    pip --version
    

3. Alternative: Re-run the Official Python Installer

If you prefer a GUI fix without editing environment variables manually:

  1. Re-run the official Python .exe installer from python.org.
  2. Choose Modify, verify “pip” is checked, click Next, check “Add Python to environment variables”, and click Install.

Common Causes & Fixes Summary

Root Cause Diagnostic Symptom Solution
Scripts\ folder missing from PATH py -m pip --version succeeds, but pip --version fails Add ...\Python3XX\Scripts to User PATH and restart terminal.
pip was omitted during installation py -m pip --version prints No module named pip Run py -m ensurepip --upgrade to install the bundled pip.
Virtual environment not activated pip works globally or in another folder, fails in project Activate the venv first: .venv\Scripts\Activate.ps1 (PowerShell) or .venv\Scripts\activate.bat (CMD).
Terminal opened before Python install Installed Python with PATH checked, still fails in open shell Close all Command Prompt / PowerShell / VS Code terminals and open a new one.