Installing Pip on Ubuntu System is a very simple task. Before you install it on your system let us share some important information about pip.
Pip is nothing but a tool that is used for installing Python packages. Using pip you can search, download and install python packages from a package index PyPi. PyPi generally means Python Package Index.
In this article, you will learn how to install pip on your Ubuntu machine in easy steps. This article is not just about installing pip on your system but also from this article you will gather some really useful about pip and Ubuntu.
Table of Contents
Python and Pip
If you are a developer and have been using the Linux system for development then you must know that Python has two popular versions that are being used by Linux users that are Python 2 and Python 3.
When you install Ubuntu you get Python 3 by default with base installation. Ans using Universe Repository you can Install Python 2.
If you want to install a python module for global use you must install it using deb package. In such a case you will have to use apt tool.
If we talk about Python 2 and Python 3 package prefix you will be find Python 2 comes with python2- prefix and Python 3 packages comes with python3- prefix.
In the case you want to download and install a module globally using pip then we suggest you to install it only if there is no deb package available for the module. Deb Packages for global use are tested to work fine on the Ubuntu system.
You will learn in this article to-
- Installing Pip for Python 2
- Installing Pip3 for Python 3
- Pip Basic Tutorial
- How to use Pip3
- Pip3 Basic Commands
- Pip3 packages
- Install Packages with pip3
- Uninstall Packages with pip3
- upgrade packages
Install Pip for Python 2
Enable Universe Distribution Component
Run the following command in order to enable Universe Repository on your machine-
$ sudo add-apt-repository universe
$ sudo apt update
Now install Python 2
Run the following command-
$ sudo apt install python2
When you run the given command to install Python 2, You will be asked if Do you want to continue the installation. Here, you will have to press Y and hit Enter. The installation will be completed within a few seconds.
In order to install pip for python 3 we will use get-pip.py script.
Run the given command to install curl because we will use curl to download get-pip.py-
$ sudo apt install curl
Curl is basically a download tool. We are about to download get-pip.py script so it was important to install curl tool.
Download get-pip.py by running the following command on your terminal–
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
Once you run the given command the pip will be downloaded now its time to install pip.
Install pip for Python 2
$ sudo python2 get-pip.py
After running the given command the latest version of pip will be installed on your ubuntu system.
To verify the pip installation on your Ubuntu run the given command to check installed pip version. The version will be shown up only if pip is installed on your sytem.
$ pip2 --version
Output should be like this-
pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Note: The version may be different.
Install Pip for Python 3
Installing pip for python 3 is much easier than installing it for Python 2. In order to install pip for python 2 on Ubuntu run the following command-
$ sudo apt update
$ sudo apt install python3-pip
The sudo apt install python3-pip will not only install pip for python 3 but also it will install the dependencies that are used for creating or building python modules.
After installing pip for python 3 you can verify if the package is installed on your system. In order to check it out, you will have to check pip version by running the given command-
$ pip3 --version
The output should look like-
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
However, version could be different.
Pip Basic Tutorial
We guess you should have some basic knowledge about pip in order to use it properly.
How to Use Pip
As you know using pip you can download and install packages from Python Package Index (PyPi). Let’s have a look at Basic Pip Commands.
Pip Basic Command
install – User for Installing Packages
uninstall – Used for Uninstalling Packages
download – The download command is used for downloading packages
freeze – The free command is used to get output installed packages in required format.
list – The is list command lists the installed packages
show – The show command display information about installed packages.
check – It verifies if the installed packages have compatible dependencies.
config – This command is for managing local and global configuration.
search – The command in pip used for searching packages.
help – It displays help commands.
debug – It displays information useful for debugging.
In order to install any package from python package index, you must know the name of the particular package.
So what are some popular pip3 packages?
Well, here is the list of some popular pip3 packages-
There are just a few pip3 packages. But you can get the complete list of Packages. by running the following command-
$ pip3 list
Install Packages using Pip3
The process of Installing packages using pip3 is also similar to installing deb packages but you will have replace apt with pip3. look at the syntax-
$ pip3 install [PackageName]
Suppose you want to install apturl package using pip3 then you will have to run the following command-
$ pip3 install apturl
Uninstall Pip3 Package
Sometimes may need to uninstall pip3 Packages from your machine. In such a case, you will have to run the following command-
$ pip3 uninstall [PackageName]
$ pip3 uninstall apturl
Upgrade Packages With Pip
Packages can also be upgraded using the following upgrade command-
$ pip3 install --upgrade [PackageName]
In this post, we have covered pip and pip3 for python2 and Python3. Also we have shared some deep information about pip and pip3. If you have completed reading this article then you must have how to install pip on Ubuntu system, How to install packages with pip, How to uninstall Packages eith pip and How to upgrade Packages. If you have any confusion then please let us know throgh comment section.