Sunday, September 20, 2020

How to install pip on windows | Tutorial

 What is PIP? 

Full form of PIP: Prefered Installer Program

PIP is one of the important tools in Python. It servers as the standard package manager for Python. It allows you to download and install different packages that are not part of Python standard packages.

In this tutorial, we will learn:


How To install PIP on windows?

Prerequisites 
  • A system running on windows or windows server.
  • Administrator privileges.
  • Pre-installed Python environment.
Step 1 (checking if pip is already installed):
Before Installing pip check whether pip is already installed.
Type the following command in the command prompt and hit enter.
pip --version

If pip is already installed then your system will recognize the command then it will return the current version of the pip that is installed on your system.
pip 20.2.3 from c:\users\username\appdata
\local\programs\python\python38-32\lib\
site-packages\pip (python 3.8)

Else it will return an error
'pip' is not recognized as an internal or
external command,operable program or 
batch file.

Step 2 (downloading get-pip.py):
If pip is not installed then download the 'get-pip.py' file from this link to the desired folder.
*Note: If your browser opens the text file instead of downloading the 'get-pip.py' file then copy that entire text to the notepad and save it as get-pip.py.  
save as window
Save As window

Step 3 (running CMD):
In the windows-search bar type cmd then right-click on the command prompt and run it as administrator.

Step 4 (installing pip):
Navigate to the file or folder using the 'cd' command followed by the folder path in cmd to the folder where get-pip.py is saved or downloaded. For example, I have downloaded the file at 'Downloads' so I will change my current directory of cmd to download using the following command.
cd downloads

Step 5 (installing pip):
Once you are in the folder, type "python get-pip.py" and hit enter.
python get-pip.py
It should start the pip installation process, but in case if you encounter any kind of error or interruption than you can check for the following things:
  • Make sure CMD is running as an administrator.
  • Make sure you are working on the same directory/folder where you have downloaded get-pip.py
  • Make sure python is already installed in your system.
  • Check whether the downloaded file is corrupted.
Step 6 (last step):
If installation completes without any interruption then check the pip version using 'pip --version' to confirm the installation.
*Note: If you get the following error then add python to windows path.

‘pip’ is not recognized as an internal or external 
command, operable program or batch file
 
In this section, we will learn some of the pip commands that are most commonly used.

How to download and install packages using pip?

Run cmd and type 'pip install' followed by the package name you want to install.
For example, if I want to install the 'numpy' package then I will run the following command.

pip install numpy
This command will download the numpy package in my system and now I can easily import numpy in my python projects to use it. 

How to uninstall packages using pip?

To remove the installed packages from your computer run cmd and type "pip uninstall" followed by the package name.
For example, if I want to remove the numpy package then I will type the following command.
pip uninstall numpy
*Note: while removing packages make sure you run cmd in administrator mode


To check the pip version run cmd and type "pip --version" and hit enter.
pip --version
It will return the pip version in the following format.
pip 20.2.3 from c:\users\username\appdata
\local\programs\python\python38-32\lib\
site-packages\pip (python 3.8)

How to upgrade PIP?

In order to upgrade pip version run cmd as administrator mode and type the following command.

python -m pip install --upgrade pip
This command will upgrade the current version of the pip on your system to the new version if available.
*Note: If you get the following error then add python to windows path. click here 

‘pip’ is not recognized as an internal or external 
command, operable program or batch file

4 comments:

  1. Very helpful article after reading it installing pip on my pc became so easy

    ReplyDelete
  2. This tutorial helped me a lot thank you.

    ReplyDelete
  3. Thanks for this article after reading this installing pip became so easy.

    ReplyDelete