Cloud Service >> Knowledgebase >> General >> Learn to Install PIP on Windows
submit query

Cut Hosting Costs! Submit Query Today!

Learn to Install PIP on Windows

PIP (Pip Installs Packages) is an essential Python package manager that allows you to install and manage additional libraries and dependencies for your Python environment. PIP unlocks Python's vast ecosystem of over 150,000 packages to boost your coding capabilities.

This in-depth guide provides everything required to fully install, set up, and utilize PIP on your Windows system. Topics covered include:

  • Prerequisites

  • Differences between PIP, PIP3, and PIP2

  • How to check if PIP is already installed

  • Installing or upgrading PIP using the get-pip script

  • Installing PIP packages using the Python command line

  • Managing packages with pip commands like install, freeze, uninstall etc.

  • Configuring virtual environments with PIP

  • Common troubleshooting issues and solutions

Prerequisites

Before installing PIP, you need:

  • Python already installed on your Windows server system. PIP works with Python 2 versions 2.7 or greater or Python 3 versions 3.4 or greater.

  • An internet connection to download packages and dependencies.

  • Administrative rights on your machine to install software.

PIP vs PIP3 vs PIP2

  • PIP refers to the package manager that works with Python 2.7+

  • PIP3 is specifically for Python 3.4+

  • PIP2 is now obsolete and refers to PIP versions designed for the end-of-life Python 2.6

 

So make sure you use the PIP version corresponding to your Python installation.

Check for Existing Installation

Prior to installation, confirm whether PIP is already installed.

You can check by opening the Windows command prompt and typing:

pip --version

If PIP is installed, the command will display the installed version number. If not, it will give an error saying “pip” command not found.

You can also check for PIP3

pip3 --version

Install or Upgrade with get-pip.py

If you need to install or upgrade PIP, the simplest method is using the get-pip.py script. Follow these steps:

  1. Download get-pip.py from https://pip.pypa.io/en/stable/installation/

  2. Move the downloaded get-pip.py file to your Python installation directory. The default path is usually C:\Users\YourName\AppData\Local\Programs\Python\Python36.

  3. Open a command prompt as administrator and navigate to the Python install directory.

  4. Run the command:

 

python get-pip.py

This will install the latest version of PIP for your Python environment.

To upgrade an existing old PIP version, rerun the get-pip.py command.

Installing PIP Packages and Modules

Once PIP is installed, you can start installing Python packages

Packages are installed using the pip install command in cmd or powershell.

For example, to install the widely used Requests module, run:

pip install requests

This will download the Requests package and its dependencies from the Python Package Index repository and install it for use in your Python environment.

Some other common PIP commands include:

pip install # Install a package

pip uninstall # Uninstall a package

pip list # List installed packages

pip show # Show info about an installed package

pip freeze > requirements.txt # Export installed packages to a requirements file

pip install -r requirements.txt # Install packages from a requirements file

PIP allows you to install Python packages either globally to make them accessible system-wide, or within a virtual environment to isolate them on a per-project basis.

Virtual Environments with PIP

It's recommended to use PIP with virtual environments to manage dependencies on a per-project basis.

To create a virtual env:

python -m venv myenv

This will generate a new folder called myenv containing an isolated Python environment.

Activate it on Windows by running:

myenv\Scripts\activate

Install packages within this virtual env and they will only be accessible when the env is activated.

Common Issues and Solutions

Here are some common PIP installation issues and how to fix them:

  • Permission errors on Windows: Run your command prompt as Administrator

  • "pip not recognized" error: Ensure pip is installed and the PATH environment variable is set to include Python'sScripts folder

  • Old version installing: Upgrade with get-pip.py or pip install --upgrade pip

  • Requirements file not found: Specify the correct file path or install packages individually

  • Packages not installing: Check your internet connection and try again. Use --default-timeout=100 to increase timeout.

  • Cannot uninstall package: Use pip uninstall -y package-name to forcefully uninstall

Summary

In this guide, you learned how to install and use PIP to manage Python packages on Windows:

  • Use get-pip.py to install or upgrade PIP for your Python environment

  • Install packages globally or in virtual environments using pip install

  • Manage installed packages with freeze, list, show and uninstall

  • Fix common issues like permissions errors or version problems

With PIP enabled, you can now easily access Python's extensive collection of libraries and modules to help build your programs and automate tasks using Python code.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!