X

How to Install Python Package Manager Pip on Ubuntu

Have you ever wondered why Python installation and setup is so fast and easy for all that it promises? This is thanks to its standard package manager, called pip. Python itself comes with very basic built-in modules, but the most powerful modules that make Python a powerhouse are not included in the basic installation of Python.

Any package in PyPI (the Python Package Index) can be installed, uninstalled, updated, and so on with the package manager called pip. Python Package Index (PyPI) is an extensive library that was developed by the Python community and has brought a huge amount of application development.

In this article, you will learn to install and use pip to manage packages within Python. Additionally, this article goes over the installation of the pip version that is compatible with Python2.

Prerequisites

  • Ubuntu or any other Linux-based distribution
  • A user account with root or sudo privileges
  • Terminal access
  • Internet access

Note: Despite the fact that the commands used in this tutorial are particular to the Ubuntu operating system, all of the approaches are applicable to any Linux-based machine.

Find the Current Python in Use

See the current Python in use with the following command.

sudo python3 --version

Update your System

Update the system to make sure repositories are up to date using the following apt command.

sudo apt update

Install pip for Python 3

You can install pip for Python 3 with the following command.

sudo apt install python3-pip

Find pip3 Version

Run the following command to check the version of pip3.

pip3 --version

Install pip for Python 2

Python 3 is the only version that comes by default in Ubuntu. While Python 2 is no longer supported, it is still used in some cases, such as virtual environments.

Enable Universe Repository

First, you need to enable the Universe repository with the following apt-get command.

sudo add-apt-repository universe

Update Your System

Update your system as recommended.

sudo apt update

Install Python 2

Next, install Python 2 on your system with the following apt command.

sudo apt install python2

Download pip Installation Script

Use the following curl command to download the pip2 installation script.

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

Install pip2

Run the pip2 installation script to install pip2.

sudo python2 get-pip.py

Find pip2 Version

Now, you can check the pip2 version.

pip2 --version

Use pip to Install Python Packages

To install Python packages through pip, run the following command with your package name.

pip3 install <Package -name>

Use pip to Upgrade Python Packages

You can also upgrade the installed packages with pip.

pip3 install --upgrade <Package -name>

Use pip to Uninstall Python Packages

Use the following command to uninstall packages when needed.

pip3 uninstall <Package -name>

Use pip to List Python Packages

You can list the Python packages with pip.

pip3 list

More About pip

You can find out more about pip by using the following commands.

pip3 --help

Or

pip3 install --help

Conclusion

Pip is a Python package manager. That is, it is a tool that allows you to install, update, and manage packages, requirements, and their dependencies.

Additionally, you can search for, download, and install packages from the Python Package Index (PyPI) and other package indexes using pip. It also manages requirements for your applications and scripts. And it can uninstall packages and dependencies.

In this article, you have learned about its installation in different versions of Python and its use on the Ubuntu operating system.

Karim Buzdar: About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various websites.
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings