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.
- How to Check Whether pip Is Already Installed on Windows
- Prerequisites for Installing pip in Windows
- How to Get Started with pip on Windows
- 1. Download and Install pip
- 2. Add pip as an Environment Variable in Windows
- 3. Upgrade and Downgrade pip
- Using pip to Manage Python Packages in Windows
- Frequently Asked Questions
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.
- Open Command Prompt from Windows Search and run it as an administrator.
- Run either of the following two commands to verify Python’s presence on your Windows device:
python --help
python --version
- The
python --help
command will tabulate a list of all available Python arguments to be used on your device.
- 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.”
- Type the following in the Command Prompt to check for pip’s availability.
pip help
- The
pip help
command will tabulate a list of commands and general options to be used with thepip
script.
- 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.
- Open Command Prompt in administrator mode.
- Type the following without any arguments and hit Enter.
python
- The latest version of Python will show up on a Microsoft Store window. Click “Get” to download the software.
- 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
- Open the Command Prompt in administrator mode.
- 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
- View the above file downloading on your device along with a stream of values for the received data packets.
- Use a Python
get()
request to download the file from its source.
python get-pip.py
- After Python collects the required packages for pip, wheel, and other scripts, you may see a few warning messages that can be safely ignored.
- 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.
- 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.
- Type
%AppData%
within the Run command (Win + R), taking you to AppData’s Roaming folder.
- 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.
- Save the “get-pip.py” file you downloaded earlier in the same folder as your other Python applications.
- 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.]
- Run Python’s bootstrapping script, “get-pip.py,” to install pip on your Windows machine.
python get-pip.py
- 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.
- 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.”
- Go to the “Advanced” tab in the System Properties window.
- Click the “Environment Variables” button at the bottom.
- Double-click the “Path” environment variable.
- Click “New” to create a new environment variable.
- Copy-paste the entire Python subfolder path as shown in the previous section. Click “OK” to confirm.
- 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:
- Type the following arguments in the code to upgrade pip.
python -m pip install -U pip
- 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.”
- Type the following to downgrade pip:
python -m pip install==[older version number]
- 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:
- To install a new package using pip, enter the following information:
pip install [name of the package]
- In this example, pip is being used to install
Pandas
, a complete Python package that performs data analysis on a wide variety of datasets.
- Type the following to uninstall a Python package with pip.
pip uninstall [name of the package]
- 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 outputpip search
: search for available package informationpip check
: check whether there are any broken requirements in the packagepip download
: download a package filepip 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.
Our latest tutorials delivered straight to your inbox