How to Install pip in Windows to Manage Python Packages

Spread the love

Windows uses a package management software called pip, a standalone program, to execute different Python packages for installation, uninstallation, downloads, search queries, and more. You will first have to check whether pip and Python are already installed on your computer. If not, follow these step-by-step instructions to install pip in Windows and use it to manage Python packages.

Good to know: see how to run a Java program from Command Prompt.

Content

How to Check Whether pip Is Already Installed on Windows

Before running pip on your Windows device, run a few commands as shown to verify whether pip and Python are already installed as programs on your PC.

  1. Open Command Prompt from Windows Search and run it as an administrator.

  1. Run either of the following two commands to verify Python’s presence on your Windows device:
python --help
python --version
  1. The python --help command will tabulate a list of all available Python arguments to be used on your device.

  1. If Python is not available on your device, you will see a notification that says: “Python was not found; run without arguments to install from the Microsoft Store or disable this shortcut from Settings > Manage App Execution Aliases.”

  1. Type the following in the Command Prompt to check for pip’s availability.
pip help
  1. The pip help command will tabulate a list of commands and general options to be used with the pip script.

  1. If pip was not installed earlier, the code will return the following output: “pip is not recognized as an internal or external command.”

Tip: check out these Python one-liners you should know about.

Prerequisites for Installing pip in Windows

Other than having access to a terminal emulator, such as Command Prompt, there is only one prerequisite before you can install pip in Windows. You just need Python. If it’s not on your PC, you will first have to download and install it.

You can download the latest version of Python from its official website, but it’s much easier using Microsoft Store, where you get Python’s latest stable version for Windows without having to deal with any installer files.

  1. Open Command Prompt in administrator mode.
  2. Type the following without any arguments and hit Enter.
python

  1. The latest version of Python will show up on a Microsoft Store window. Click “Get” to download the software.

  1. Once the process is complete, you will find Python in your list of installed apps.

How to Get Started with pip on Windows

Follow these step-by-step instructions to install pip on your Windows computer and make it usable for Python packages.

1. Download and Install pip

To install the pip package, you will need to first download and set up a bootstrapping script called “get-pip.py.” There are two different ways to complete the download instructions for the script in question.

Tip: learn the differences between Command Prompt and Powershell to know which one to use and when.

Command-Line Installation

  1. Open the Command Prompt in administrator mode.
  2. Assuming Python is installed on your Windows computer, execute its cURL command to bootstrap the “get-pip.py” file from its official URL webpage.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  1. View the above file downloading on your device along with a stream of values for the received data packets.

  1. Use a Python get() request to download the file from its source.
python get-pip.py
  1. After Python collects the required packages for pip, wheel, and other scripts, you may see a few warning messages that can be safely ignored.
  2. Upon successful installation of pip, you will see a message that says, “Successfully installed pip [version number] wheel [version number].”

Manual Installation

Apart from the command-line interpreter method, you can install pip manually through its original webpage.

  1. Go to the bootstrap file download location and save it in any Windows folder for use in the next steps. In the following example, we are saving it to the “Downloads” folder.

  1. Type %AppData% within the Run command (Win + R), taking you to AppData’s Roaming folder.

  1. Move one level up in the folder tree to access the “Local” subfolder. It contains the Python files under “Microsoft/WindowsApps.” The precise location of this Python subfolder varies from one PC to another.

  1. Save the “get-pip.py” file you downloaded earlier in the same folder as your other Python applications.

  1. Go back to the Command Prompt and use the cd command to change its directory path based on your Python subfolder location.
cd [path to Python subfolder and get-pip file.]

  1. Run Python’s bootstrapping script, “get-pip.py,” to install pip on your Windows machine.
python get-pip.py

  1. The software is installed once you see a “Successfully installed pip with version number” message – but the job is only half done. There’s still more to do, so keep reading.

FYI: unable to start the Windows troubleshooter? Learn what to do about it.

2. Add pip as an Environment Variable in Windows

You can always run pip from its stored folder tree path, as shown above, but doing it all the time can become tedious and cumbersome. It is much easier to define pip as an environment variable, allowing you to run pip just as easily from any other folders on your device.

  1. Open “Edit the system environment variables” from the search menu. It can also be opened from Control Panel along the path “System and Security -> System -> Advanced System Settings.”

  1. Go to the “Advanced” tab in the System Properties window.
  2. Click the “Environment Variables” button at the bottom.

  1. Double-click the “Path” environment variable.

  1. Click “New” to create a new environment variable.

  1. Copy-paste the entire Python subfolder path as shown in the previous section. Click “OK” to confirm.

  1. You can run pip from any folder path in Windows.

Tip: you can use the Windows Package Manager to install and update software as demonstrated in this guide.

3. Upgrade and Downgrade pip

As with any other software package, pip has to run up to date with your current system. You can easily upgrade or downgrade pip on your device with a few simple commands, as shown below:

  1. Type the following arguments in the code to upgrade pip.
python -m pip install -U pip
  1. If you already have the latest pip package, you will see a notification that says, “Requirement already satisfied: pip in ‘folder path unique to your system’ with package version number.”
  1. Type the following to downgrade pip:
python -m pip install==[older version number]
  1. The following screen shows pip’s progressive downgrade from version 23.1.2 to 22.0, followed by upgrading it back to the original version.

Good to know: learn how to pretty print a JSON file in Python using the Terminal and command line.

Using pip to Manage Python Packages in Windows

After you’ve installed pip in Windows, you can readily use it to control and execute a wide variety of Python packages. Let’s check out two important commands that many Python users require frequently:

  1. To install a new package using pip, enter the following information:
pip install [name of the package]
  1. In this example, pip is being used to install Pandas, a complete Python package that performs data analysis on a wide variety of datasets.

  1. Type the following to uninstall a Python package with pip.
pip uninstall [name of the package]
  1. The pandas package is uninstalled with a simple pip command.

There are a few more popular pip commands that you will encounter when dealing with various Python packages:

  • pip inspect: inspect a Python environment to produce a JSON output
  • pip search: search for available package information
  • pip check: check whether there are any broken requirements in the package
  • pip download: download a package file
  • pip wheel: build a new project using your current dependencies and requirements

FYI: to learn more about Python’s one-liner commands, check out this useful list.

Frequently Asked Questions

How do I uninstall pip from Windows?

Use pip’s own uninstallation command with the syntax pip uninstall pip. This will not uninstall Python from your Windows machine.

Can I install pip offline?

If you’ve previously downloaded the pip packages from its online source, you can install it without connecting to the Internet. You can also install pip on Unix or Mac.

How can I deal with the “pip command not found” error on Windows?

When you encounter a “pip command not found” error in Windows, it means you may have made a mistake while editing the environment PATH variable for the pip command. To remedy this, go to Control Panel and edit the environment variable with correct spelling, and ensure that it points to the same path as your Python subfolder’s location in “AppData.”

Image credit: Pixabay. All screenshots by Sayak Boral.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Sayak Boral
Staff Writer

Sayak Boral is a technology writer with over eleven years of experience working in different industries including semiconductors, IoT, enterprise IT, telecommunications OSS/BSS, and network security. He has been writing for MakeTechEasier on a wide range of technical topics including Windows, Android, Internet, Hardware Guides, Browsers, Software Tools, and Product Reviews.

Comments are closed