Linux Mint

How to Install PIP in Linux Mint 20

PIP is a command-line utility that helps you to install various Python packages on your system. It allows you to search and install the packages from the python package index and other package index repositories. PIP does not come installed in Linux Mint; however, it can be installed easily.In this tutorial, we will describe to you how to install PIP in the Linux Mint system. We will cover the installation of PIP utility for both Python 2 and Python 3.We have explained the procedure and commands on Linux Mint 20 OS. More or less, the same procedure can be followed in older Mint versions.

Note: For installing or removing any package in any Linux distribution, including Linux Mint, you must be root user or normal user with sudo privileges. Moreover, we will be using the command line Terminal application for the installation process. To open the command line Terminal, use the Ctrl+Alt+T keyboard shortcut.

Installing PIP for Python 3

For Python 3, you will need to install the PIP3 package. Python 3 is already installed on Linux Mint 20 system. You can verify it using the following command in Terminal:

$ python3 --version

If it is installed, you will see the following similar output.

Now to install PIP for Python3 in you Linux Mint system, follow the below procedure:

1. Update the system repository index using the following command in Terminal.

$ sudo apt update

When prompted for the password, provide a sudo password.

2. Then install PIP for Python 3 using the following command in Terminal:

$ sudo apt install python3-pip

After running the above command, the system might ask for confirmation that if you want to continue the installation or not. Press y to continue; after that, the installation of PIP will be started on your system.

3. Once the installation of PIP is completed, you can verify it using the following command in Terminal:

$ pip3 --version

From the output, you will see a version number similar to this, which implies that the PIP has successfully installed on your system.

Installing PIP for Python 2

For Python 2, you will need to install PIP2. PIP2 package does not exist in the official Mint repositories. However, you can install it using the get-pip.py script. Follow the below steps to install PIP for python 2.

1. Add the required repository using the following command in Terminal:

$ sudo add-apt-repository universe

2. Then update the system’s repository index with that of the newly added universe repository. Issue the following command in Terminal to do so:

$ sudo apt update

3. Python2 is not installed by default in the Linux Mint 20 system. You can install it with the following command in Terminal:

$ sudo apt install python2

To verify if PIP is successfully installed, issue the following command in Terminal:

$ python --version

4. Download the get-pip.py script. Issue the following command in Terminal to do so:

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

5. Now, run the get-pip.py script as the sudo user. Issue the following command in Terminal to do so:

$ sudo python2 get-pip.py

6. You can verify the installation using the following command in Terminal:

$ pip2 --version

The above output shows that the PIP for python2 has been successfully installed.

Using PIP

Now that you have learned to install PIP for python 3 and python 2, let’s have a look at some of the basic and useful PIP commands.

The following are the basic PIP commands that work with PIP3. If you have installed PIP2, just replace “pip3” with “pip”.

View help

To view all the PIP commands along with their options and a brief description, you can use the following command in Terminal:

$ pip3 --help

Search for a package

To search for a package whose name or description contains a matching <keyword>, use the following command syntax:

$ pip3 search <keyword>

For instance, if you search for a keyword “vlc”, it will return all the packages whose names or description contains the keyword “vlc”.

$ pip3 search vlc

Install a package

To install a package using PIP, use the following command syntax:

$ pip3 install <package_name>

For instance, to install vlccast package, the command would be:

$ pip3 install vlccast

Remove a package

To remove a package installed via PIP, use the following command syntax:

$ pip3 uninstall <package_name>

For instance, to remove vlccast package, the command would be:

$ pip3 uninstall vlccast

List packages

To list all the installed PIP packages, use the following command in Terminal:

$ pip3 list

View installed package information

To view installed package information, you can use the following command syntax:

$ pip3 show <package_name>

For instance, to search for information regarding the installed “vlccast” package, the command would be:

$ pip3 show vlccast

Uninstalling PIP

In case, you want to uninstall PIP3 from your system, use the following command in Terminal:

$ sudo apt purge pip3

In case, you want to uninstall PIP2 from your system, use the following command in Terminal:

$ sudo apt purge pip

This is how you can install and use PIP in Linux Mint 20 system. You have also learned how to uninstall PIP if you no longer need it. I hope it will be helpful for you!

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.