How To Install and Upgrade Pip on Windows/Linux?

Pip is a powerful command-line Python Package manager for managing Python packages and libraries. It allows users to easily search for and install various Python packages, including all dependencies from Python Package Index (PyPI) and other different sources.  

In this guide, we will explore how to install Python packages using pip on Windows and Linux operating systems. Moreover, we will also demonstrate how to upgrade pip to the latest version using the command line.

how to install and upgrade pip on windows/linux?

Source: https://pypi.org/project/pip/

How To Install Python Pip on Linux/Windows OS?

Before using pip, it is necessary to install Python on your system. In most modern distributions, Python comes pre-installed. You can check your Python version using the following command:

> python

As a result, the installed Python version will display on the command prompt. 

If Python is not installed, you can get it from its official website. Once you install Python, you can move on to install the pip Python package manager on Windows or Linux. Let’s explain how to do so.


How to Install Pip on Windows?

Pip usually comes pre-installed with Python to manage package versions and updates exclusively. However, if it is not installed on your Windows system, you can install it manually using the below steps: 

  1. Download the Python pip script on your system. To do this, open the get-pip.py Python script and right-click on the script page. Select ‘Save as’ to download this installer on your system.


how to install and upgrade pip on windows/linux?

  1. Locate the directory using the ‘cd Downloads’ command and install pip using the following command:


> python get-pip.py

  1. You can verify the installation using the ‘pip --version.’


> pip -V

Or 

> pip –version

how to install and upgrade pip on windows/linux?

How to Install Pip on Linux?

To install pip on Linux distribution, follow these steps:

  1. Update and upgrade the system apt repositories:


$ sudo apt update && sudo apt upgrade

  1. Now, check the Python installation using this command:


$ python3 –version

how to install and upgrade pip on windows/linux?

If it is not installed, you can install Python using ‘sudo apt install python3’.

  1. To install the Python pip package, use the following command:


$ sudo apt install python3-pip

how to install and upgrade pip on windows/linux?

Press ‘y’ to continue the pip installation. The above command will install Python pip3 package on your Linux system. Now, you can verify the pip installation using this command:

$ pip --version

The installed version will display on your terminal window.

how to install and upgrade pip on windows/linux?

The next question is, how to update pip? All you need to do is follow a few simple steps to update pip, so let’s cover them in detail.

How To Upgrade Pip to the Latest Version? [PIP Update]

If you are using an older version of pip on your Linux or Windows operating system, you can easily upgrade pip. In this section, you will learn how to upgrade pip to the latest Linux/Unix and Windows OS versions.

How to Upgrade Pip in Windows? 

To ensure pip is up-to-date and functioning optimally, it's recommended to periodically upgrade pip. To upgrade pip on Windows, execute the following command:

> python -m pip install --upgrade pip

Or alternatively:

> pip3 install --upgrade pip

how to install and upgrade pip on windows/linux?

The above command will initiate the pip update process. By running this command, pip will connect to PyPI, check for the latest version of pip, and then download and install it if a newer version is available. There you have the answer on how to upgrade pip. 

When you upgrade pip to the latest version, it guarantees access to new features, security enhancements, and bug fixes, thus maintaining a smooth and efficient package management workflow in Python.

Similar to when you upgrade pip, you can easily downgrade your pip version using the pip command:

>python -m pip install pip==22.3 

How to Upgrade Pip in Linux?

The Linux operating system also allows you to install Python packages and upgrade pip. To upgrade pip on Linux, follow these steps:

First, check the current version of pip using the terminal command:

$ pip --version

Now, upgrade pip to the latest version using this command:

$ sudo pip install --upgrade pip

how to install and upgrade pip on windows/linux?

Once the pip update process is completed, you can verify whether a new pip release is installed or not on your system, i.e., whether you were successful in your upgrade pip.

How To Manage Python Packages Using Pip?

As mentioned, all Python packages are registered in the PyPI repository. You can install, update and uninstall Python packages on your system using pip.

Install Python Packages with Pip

To install a new Python package from the PyPI repository, use the following syntax:

> pip install <package-name>

For example, let’s say you want to install a package ‘scrapy’ from the PyPI repository. Execute the following command:

> pip install scrapy

The above command will install this package on your system in a few seconds.

how to install and upgrade pip on windows/linux?

If you are unable to install packages from the PyPI repository due to bugs or errors, you can install packages from your local system directory and GitHub repository.  

Install Python Packages from A Local Repository

To install a Python package from a local directory, you need to specify the file path where it is located in your system and provide the file name:

> pip install file-path/[file-name]

Install Python Packages from the Git Repository or GitHub

If you are installing a package from Git, use the following syntax:

> pip install git+<git-repository-url>

> pip install git+https://github.com/[Github-user-name]/[name-repository]

It is important to note that when you install a package using ‘git+,’ Git should be installed on your system. The above command will perform a git clone operation during the package installation with pip.

List Installed Packages with Pip

You can also list the installed Python packages using the pip command. To list all packages, use the following command:

> pip list

how to install and upgrade pip on windows/linux?

> pip freeze

how to install and upgrade pip on windows/linux?

The above commands will display the list of installed packages on the command prompt. But ‘pip freeze’ will not display the pip packages used for package management, such as wheel, pip, and setup tools.

If you want to display the information about a specific installed package, execute this command instead:

>pip show psutil

The above command will display the details on the terminal screen.

how to install and upgrade pip on windows/linux?

Update Or Upgrade Pip Packages [Pip Update]

If you don’t want to install a new package version, pip allows you to update the installed packages to their latest available versions. To update a package with pip, use the below command:

> pip install --upgrade <package-name>

For example, if you want to update the above-installed package ‘scrapy’, type the following command:

>pip install --upgrade scrapy

Uninstall Packages with Pip

Using pip, you can uninstall or remove the already installed Python package from your system. To uninstall a package using pip, use the below command:

>pip uninstall <package-name>

> pip uninstall scrapy

After executing the above command, the package will be uninstalled from your system, and you will see the following output:

how to install and upgrade pip on windows/linux?

Conclusion

In this guide, we have explored the installation and upgrading of pip on both Windows and Linux operating systems. Pip is an essential tool for Python developers, simplifying the process of managing Python packages and libraries. The ability to install, upgrade pip, and uninstall packages with ease enhances the efficiency of the development workflow. 

Additionally, when you upgrade pip, the pip update ensures access to the latest features, security enhancements, and bug fixes, maintaining a reliable package management environment. By mastering the commands and processes detailed in this guide, you can upgrade pip, and effectively manage Python libraries and packages, thereby enhancing your productivity as a Python developer.