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.
-
Print the exact path to your Python
Scriptsfolder 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) -
Open the Windows Start Menu, search for “Edit environment variables for your account”, and press Enter.
-
Under User variables, select Path and click Edit.
-
Click New, paste the exact
Scriptsfolder path printed in Step 1 (and add the parentPython312folder if it isn’t listed yet), then click OK on all dialogs. -
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:
- Re-run the official Python
.exeinstaller from python.org. - 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. |
