Question

How to Install pip on Windows for Python

pythonwindowspip

Question

I want to install pip on Windows. Since pip is often described as a replacement for easy_install, should I install pip using easy_install, or is there a better and more standard way to set it up on Windows?

Short Answer

By the end of this page, you will understand what pip is, how it relates to easy_install, and the recommended ways to get pip working on Windows. You will also learn how to verify the installation, use basic pip commands, and avoid common setup problems such as PATH issues or using the wrong Python interpreter.

Concept

pip is Python’s standard package installer. It is the tool most Python developers use to install third-party libraries such as requests, flask, or numpy.

Older Python workflows sometimes used easy_install, which came from setuptools. Over time, pip became the preferred and standard tool because it is better at dependency handling, uninstalling packages, and working with modern Python packaging.

On Windows, the best way to get pip usually depends on how Python was installed:

  • If you install Python from the official Python installer, pip is normally included automatically.
  • If pip is missing, you can often install or restore it using Python itself, usually with ensurepip.
  • Using easy_install to install pip is generally not the preferred modern approach unless you are dealing with an older Python setup.

Why this matters in real programming:

  • Most Python tutorials assume pip is available.
  • Project dependencies are commonly installed from a requirements.txt file using pip.
  • Virtual environments rely on pip for isolated package management.
  • Modern tooling such as venv, pytest, and web frameworks is built around normal pip usage.

So the main idea is simple: on Windows, prefer installing Python correctly first, then use the built-in ways to access or restore pip instead of reaching for easy_install.

Mental Model

Think of Python as a smartphone, and packages as apps.

  • Python is the phone.
  • Packages are the apps you want to add.
  • pip is the app store installer.
  • easy_install is an older installer from an earlier era.

If your phone already comes with the app store, you should use that. If the app store is missing, you restore it using the phone’s built-in tools. You would not normally install the modern app store using an outdated installer unless you were repairing a very old device.

That is how pip and easy_install differ in practice.

Take Quiz

Syntax and Examples

The most important commands on Windows are these:

python --version
python -m pip --version
python -m pip install requests

If your system uses the Python launcher, you may also see:

py --version
py -m pip --version
py -m pip install requests

Why use python -m pip?

This tells a specific Python installation to run its own copy of pip. That helps avoid confusion when multiple Python versions are installed.

Example: check whether pip is available

py -m pip --version

Example output:

pip 24.0 from C:\Python311\Lib\site-packages\pip (python 3.11)

This means:

  • pip is installed
  • it belongs to Python 3.11
  • Python knows where the package files are stored

Example: install a package

py -m pip install requests

This downloads and installs the requests package for the Python interpreter launched by py.

If pip is missing

Try:

py -m ensurepip --upgrade

Then verify again:

py -m pip --version

If Python is not installed yet

The normal approach is:

  1. Download Python from the official Python website.
  2. Run the Windows installer.
  3. Make sure the installer includes pip.
  4. Optionally enable Add python.exe to PATH.
  5. Verify installation in Command Prompt.

Example verification:

py --version
py -m pip --version

Step by Step Execution

Consider this Windows command:

py -m pip install requests

Here is what happens step by step:

  1. py starts the Python launcher

    • Windows looks for the Python launcher.
    • The launcher chooses a Python installation, often the latest installed version.
  2. -m pip runs pip as a Python module

    • Instead of searching for a separate pip.exe, Python runs the pip module directly.
    • This is more reliable when several Python versions exist.
  3. install requests tells pip what to do

    • pip reads the command install.
    • It sees that the package name is requests.
  4. pip resolves dependencies

    • It checks whether requests needs other packages.
    • If needed, those dependencies are downloaded too.
  5. Files are installed into that Python environment

    • The package is stored in the selected Python installation or virtual environment.
    • After this, Python code can usually import the package.

Small trace example:

py -m pip --version
py -m pip install requests
py -c "import requests; print(requests.__version__)"

What this sequence does:

  • First command: confirms pip exists.
  • Second command: installs requests.
  • Third command: starts Python, imports requests, and prints its version.

If the final command works, the installation succeeded.

Real World Use Cases

pip is used in many everyday Python tasks on Windows:

  • Installing libraries for scripts

    • Example: install requests to call a web API.
  • Starting web projects

    • Example: install flask or django to build a web application.
  • Working with data

    • Example: install pandas or matplotlib for analysis and charts.
  • Running test tools

    • Example: install pytest for automated testing.
  • Setting up project dependencies

    • Example:
py -m pip install -r requirements.txt
  • Managing isolated environments
    • Example: create a virtual environment for one project so package versions do not conflict with another.

In real apps, pip is usually one of the first tools you use after installing Python.

Take Quiz

Real Codebase Usage

In real projects, developers do not just run pip install randomly. They use pip in repeatable, controlled ways.

Common patterns

  • Install from a requirements file
py -m pip install -r requirements.txt

This makes project setup consistent across team members and CI systems.

  • Use virtual environments
py -m venv .venv
.venv\Scripts\activate
python -m pip install -r requirements.txt

This keeps project dependencies isolated.

  • Verify the active interpreter
python --version
python -m pip --version

This helps prevent installing packages into the wrong Python.

  • Upgrade packaging tools when needed
python -m pip install --upgrade pip setuptools wheel

This is common when build or install issues appear.

  • Use guard-style checks in setup docs or scripts

Examples in project setup instructions often say:

python -m pip --version

before any install command, so users confirm that pip is available first.

Why python -m pip is common in codebases

It avoids ambiguity:

  • pip on PATH might belong to a different Python version.
  • python -m pip ties the installer directly to the chosen interpreter.

That small habit prevents many environment bugs.

Common Mistakes

1. Using pip directly when multiple Python versions are installed

Broken approach:

pip install requests

This may install into a different Python than the one your project uses.

Better:

py -m pip install requests

or:

python -m pip install requests

2. Assuming pip must be installed with easy_install

Older advice may suggest this, but on modern Windows setups it is usually unnecessary.

Prefer:

py -m ensurepip --upgrade

or reinstall Python with pip included.

3. Confusing pip not found with Python not found

If this fails:

pip --version

it does not always mean pip is absent. It may simply not be on PATH.

Check this instead:

py -m pip --version

4. Installing packages globally when a virtual environment is better

Global installs can create version conflicts across projects.

Better workflow:

py -m venv .venv
.venv\Scripts\activate
python -m pip install requests

5. Forgetting to verify installation

After setup, always test:

py -m pip --version

and optionally:

py -c "import requests"

6. Editing PATH when it is not necessary

Many beginners try to fix everything through environment variables.

Often, on Windows, using py -m pip avoids the need for PATH changes entirely.

7. Using outdated tutorials blindly

If a guide tells you to use easy_install pip, check the Python version and age of the tutorial. Modern Python installs usually include pip already.

Comparisons

Tool or approachWhat it isRecommended on modern Windows?Notes
pipStandard Python package installerYesBest default choice
easy_installOlder installer from setuptoolsNo, usually notLargely replaced by pip
python -m pipRuns pip through a specific Python interpreterYesSafer when multiple Python versions exist
pip command aloneRuns whichever pip is on PATHSometimesCan be ambiguous
ensurepipBuilt-in way to bootstrap pip in some Python installsYesUseful if pip is missing
Reinstall Python with pip enabledFresh installation approachYesOften the cleanest fix

pip vs easy_install

  • pip can uninstall packages; easy_install historically did not handle this as well.
  • pip has become the normal package manager in Python workflows.
  • easy_install is mostly relevant for older environments.

pip vs python -m pip

They may seem similar, but python -m pip is usually more reliable because it clearly chooses which Python installation will receive the package.

Take Quiz

Cheat Sheet

Recommended commands on Windows

py --version
py -m pip --version
py -m pip install package_name
py -m pip install -r requirements.txt
py -m ensurepip --upgrade

If py does not work

Try:

python --version
python -m pip --version

Best practice

  • Prefer py -m pip ... or python -m pip ...
  • Do not use easy_install unless you are maintaining an older setup
  • Use virtual environments for projects
  • Verify after installation

Quick setup flow

  1. Install Python from the official installer
  2. Make sure pip is included
  3. Verify with:
py -m pip --version
  1. Install packages with:
py -m pip install requests

Common fixes

  • pip not found: try py -m pip --version
  • pip missing: try py -m ensurepip --upgrade
  • Wrong package location: use python -m pip for the exact interpreter

Useful commands

py -m pip list
py -m pip show requests
py -m pip uninstall requests
py -m pip install --upgrade pip

FAQ

Do I need easy_install to install pip on Windows?

Usually no. Modern Python installations on Windows typically include pip, or you can restore it with ensurepip.

How can I check whether pip is already installed?

Run:

py -m pip --version

If that prints a version, pip is installed.

What is the safest way to use pip on Windows?

Use:

py -m pip install package_name

This avoids confusion when multiple Python versions are installed.

Why does pip say command not found, but Python works?

pip may not be on PATH, even though Python is installed correctly. Try py -m pip --version instead.

Can I install pip by reinstalling Python?

Yes. In many cases, reinstalling Python from the official installer with pip enabled is the simplest solution.

Should I use pip globally or inside a virtual environment?

For real projects, use a virtual environment. It prevents dependency conflicts between projects.

Is pip included with all Python versions?

Many modern Python installers include it, but older or custom installations may not. That is why ensurepip can be useful.

What replaced easy_install?

In normal Python development, pip became the standard package installer and replaced most easy_install usage.

Take Quiz

Mini Project

Description

Create a small Windows-friendly Python setup checker that confirms Python and pip are available, then installs a package using the recommended command style. This project helps you practice the exact commands developers use when preparing a machine for Python work.

Goal

Verify that pip works on Windows and use it to install and test a real Python package.

Requirements

  • Confirm that Python or the Python launcher is available from the command line.
  • Check whether pip is installed for that Python interpreter.
  • If pip is available, install the requests package.
  • Verify the package installation by importing it in Python.
  • Use python -m pip or py -m pip rather than relying on pip alone.
Take Quiz

Keep learning

Related questions

View more