how to install pip on windows

Learn how to install pip on windows with practical examples, diagrams, and best practices. Covers python, windows, pip development techniques with visual explanations.

How to Install Pip on Windows: A Comprehensive Guide

Hero image for how to install pip on windows

Learn the essential steps to install Pip, Python's package installer, on your Windows operating system. This guide covers installation, verification, and troubleshooting.

Pip is the standard package manager for Python. It allows you to install and manage additional libraries and dependencies that are not part of the Python standard library. If you're working with Python on Windows, having Pip correctly installed and configured is crucial for any development work. This article will walk you through the process of installing Pip, verifying its installation, and setting up your environment variables.

Prerequisites: Python Installation

Before you can install Pip, you must have Python installed on your Windows system. Modern Python installers (version 3.4 and above) typically include Pip by default. If you installed Python without checking the 'Add Python to PATH' option, you might need to add it manually later. Ensure you download Python from the official website.

1. Download Python Installer

Visit the official Python website (python.org) and download the latest stable version of Python for Windows. Choose the appropriate installer (32-bit or 64-bit) for your system.

2. Run the Python Installer

Execute the downloaded .exe file. During the installation process, make sure to check the box that says 'Add Python.exe to PATH'. This step is critical as it allows you to run Python and Pip commands from any directory in your command prompt.

3. Verify Python Installation

Open a new Command Prompt (search for cmd in the Start menu) and type python --version. You should see the installed Python version. If not, Python might not be correctly added to your PATH.

Installing Pip (If Not Already Present)

As mentioned, Python 3.4+ usually comes with Pip. However, if you have an older Python version or if Pip somehow got corrupted, you might need to install it manually. The recommended way to install Pip is by using the get-pip.py script.

1. Download get-pip.py

Open your web browser and navigate to https://bootstrap.pypa.io/get-pip.py. Right-click on the page and select 'Save As...' to save the file as get-pip.py to a known location, for example, your Downloads folder or your Python installation directory.

2. Open Command Prompt

Open a Command Prompt window. Navigate to the directory where you saved get-pip.py using the cd command. For example, if you saved it in Downloads: cd C:\Users\YourUsername\Downloads.

3. Run the Installation Script

Execute the script using Python: python get-pip.py. This command will download and install Pip, setuptools, and wheel. You should see a series of messages indicating the installation progress.

cd C:\Users\YourUsername\Downloads
python get-pip.py

Example commands to navigate and run the get-pip.py script.

Verifying Pip Installation

After installing or confirming Python, it's essential to verify that Pip is correctly installed and accessible from your command line. This step ensures that you can use Pip to manage Python packages.

1. Open Command Prompt

Open a new Command Prompt window. It's important to open a new one to ensure that any changes to your system's PATH environment variable are loaded.

2. Check Pip Version

Type pip --version and press Enter. If Pip is installed correctly, you will see its version number and the location of its executable. For example: pip 23.2.1 from C:\Python39\lib\site-packages\pip (python 3.9).

3. Check Pip List

You can also try pip list to see a list of currently installed Python packages. This command confirms Pip's functionality.

Troubleshooting: Pip Not Found (PATH Environment Variable)

The most common issue after installing Python and Pip is the 'pip is not recognized' error. This usually means the directories containing python.exe and pip.exe are not included in your system's PATH environment variable. Here's how to fix it.

flowchart TD
    A[Start] --> B{Python/Pip not found?}
    B -- No --> C[Pip is working!]
    B -- Yes --> D[Check Python Installation]
    D --> E{Python added to PATH during install?}
    E -- No --> F[Manually Add Python to PATH]
    E -- Yes --> G[Check Pip's Script Directory]
    F --> H[Verify PATH]
    G --> I[Manually Add Pip Scripts to PATH]
    H --> J[Re-open CMD & Test Pip]
    I --> J
    J --> K{Still not working?}
    K -- No --> C
    K -- Yes --> L[Reinstall Python (check PATH option)]
    L --> J

Troubleshooting flow for Pip installation issues on Windows.

1. Locate Python and Pip Paths

First, find where Python is installed. Common locations are C:\PythonXX (where XX is the version, e.g., Python39) or C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX. Inside your Python installation directory, you'll typically find python.exe and a Scripts folder. The Scripts folder contains pip.exe.

2. Open Environment Variables

Search for 'Environment Variables' in the Windows Start menu and select 'Edit the system environment variables'. In the System Properties window, click the 'Environment Variables...' button.

3. Edit System PATH Variable

Under 'System variables', find and select the 'Path' variable, then click 'Edit...'. Click 'New' and add the full path to your Python installation directory (e.g., C:\Python39). Click 'New' again and add the full path to your Python Scripts directory (e.g., C:\Python39\Scripts).

4. Confirm and Apply Changes

Click 'OK' on all open windows to save the changes. Close any open Command Prompt windows and open a new one. Test Pip again using pip --version.

Using Pip to Install Packages

Once Pip is successfully installed and configured, you can start installing Python packages. This is the primary reason for having Pip, enabling you to extend Python's functionality with a vast ecosystem of libraries.

pip install requests
pip install numpy pandas matplotlib
pip uninstall requests
pip show requests
pip list --outdated

Common Pip commands for installing, uninstalling, and managing packages.

Congratulations! You have successfully installed and configured Pip on your Windows machine. You are now ready to explore the vast world of Python packages and enhance your development projects.