On Windows, pip is bundled automatically with all official Python 3.4+ installers from python—you just need to ensure “Add python.exe to PATH” and “pip” are checked during installation (or run py -m ensurepip --upgrade if it was omitted).
1. Installing pip During Python Setup (Recommended)
- Download the official Windows installer from python.org/downloads.
- On the very first installer screen, check “Add python.exe to PATH” at the bottom.
- Click Customize installation and verify that “pip” and “py launcher” are checked under Optional Features.
- Complete the installation, open a new Command Prompt or PowerShell window, and verify both
pipandPATH:
# Verify pip version and confirm it maps to your Python installation
py -m pip --version
pip --version
2. Fixing a Missing pip or PATH Issue on an Existing Installation
If Python is already installed on Windows but typing pip returns 'pip' is not recognized as an internal or external command:
# Step 1: Bootstrap or repair pip using Python's built-in ensurepip module
py -m ensurepip --upgrade
# Step 2: Upgrade pip to the latest release
py -m pip install --upgrade pip
- Adding
Scripts\to WindowsPATHmanually: Ifpy -m pipworks but barepipfails, Windows is missing Python’sScriptsfolder in your environment variables. Find its exact location and add it to your UserPATH:Open Start → search “Edit environment variables for your account” → select Path → Edit → New → paste the# Print the exact Scripts directory path (e.g., C:\Users\<You>\AppData\Local\Programs\Python\Python312\Scripts) py -c "import sys, os; print(os.path.join(sys.prefix, 'Scripts'))"Scriptsfolder path (along with the parent Python folder path) → click OK, then restart your terminal.
3. Configuring pip on Windows (pip.ini)
You can set persistent default options—such as custom package indexes, timeouts, or trusted hosts—by creating a pip.ini configuration file:
# Create the per-user pip config directory and open pip.ini
mkdir "$env:APPDATA\pip" -Force
notepad "$env:APPDATA\pip\pip.ini"
Add your preferred settings inside pip.ini:
[global]
timeout = 60
no-cache-dir = false
[install]
upgrade-strategy = only-if-needed
- Verify active configuration: Run
py -m pip config listorpy -m pip config debugin PowerShell to inspect whichpip.inilocations Windows is reading from.
Quick Troubleshooting & Command Reference
| Scenario / Issue | Windows Command | Purpose |
|---|---|---|
| Safe package installation | py -m pip install <package> |
Guarantees pip installs into the exact Python interpreter invoked by py. |
pip missing completely |
py -m ensurepip --upgrade |
Installs the bundled pip wheel without needing internet access. |
'pip' is not recognized |
Add ...\Python3XX\Scripts to User PATH |
Allows running pip directly without the py -m prefix. |
| Permission denied error | Use a virtual environment (py -m venv .venv) |
Isolates project dependencies and avoids modifying system-wide folders. |
You must log in or register to comment.
