How to Install Pip3 on Ubuntu 20.04 and Use It?

Introduction

pip is a package management tool available in Python. pip3 is a program compatible with Python 3 version.

You can install pip3 on Ubuntu using sudo apt install python3-pip command.

With pip3, you can install, update, search and uninstall packages from the PyPI package indexes and other package indexes.

In this tutorial, you’ll install PIP3 on Ubuntu 20.04 and learn how to install, manage and uninstall packages with pip3.

Step 1 – Installing PIP3

In this step, you’ll install PIP3. apt is a command-line utility to install and manage deb packages from Ubuntu and Debian-based Linux distributions.

Use apt install command with the package name python3-pip to install the pip3 package. sudo keyword is used to run the command with the administrative privileges. using sudo will install the packages globally for all users.

sudo apt install python3-pip

Now the Python3-pip is installed in your Ubuntu 20.04. It’ll be installed globally.

If you want to install it for a specific user, run the command without sudo.

[Alternate] Installing Pip3 Using Curl

As an alternative to apt install you can install pip3 using the CURL command. This can be useful when you face any issues while using the apt install command.

CURL is a command-line utility to transfer data between one server to another using the URL.

Now, you’ll copy the PIP3 setup package from the python package repository to your local server using the below command.

curl "https://bootstrap.pypa.io/get-pip.py" -o "install-pip3-ubuntu.py"

This will download the pip3 setup packages to your local machine in the name install-pip3-ubuntu.py.

You can now install pip3 by running this file using the python3 command.

python3 install-pip3-ubuntu.py

Now pip3 is installed in your server.

You can verify if it’s installed properly in the next section.

Step 2 – Verification

You can verify if pip3 is installed properly by checking its version.

pip3 --version

You’ll see the below output with the pip3 version number and the Python version number(Version number may vary).

pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

You can check out all the available commands in pip3 using the help command.

pip3 --help
Usage:
  pip3 <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependen                                                                                                                                                             cies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring
                              environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be
                              used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be
                              used up to 3 times (corresponding to WARNING,
                              ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form
                              [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should
                              attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists:
                              (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host or host:port pair as trusted,
                              even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file
                              containing the private key and the certificate
                              in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine
                              whether a new version of pip is available for
                              download. Implied with --no-index.
  --no-color                  Suppress colored output
  --no-python-version-warning
                              Silence deprecation warnings for upcoming
                              unsupported Pythons.

You can use pip3 with any of the above commands and options listed above. Commands are mandatory and options are optional.

You’ll install a package using pip3 in the next section.

Step 3 – Installing Packages With PIP3

In this section, you’ll install a package scrapy using the pip3 install command.

Scrapy is a framework for high-level web crawling and web scraping, used to crawl websites and extract structured data from their pages.

Use the below command to install scrapy with pip3.

 pip3 install scrapy

Now the scrapy package is installed in your ubuntu 20.04 machine.

If you would like to install any other package, use the package name in the place of scrapy. That package will be installed.

Step 4 – Upgrading Packages With PIP3

You can upgrade the existing packages with pip3 using the –upgrade keyword.

pip3 install --upgrade package_name

Replace the actual package name in the highlighted text to upgrade a specific package.

You’ll see how to list all the installed packages in the next section.

Step 5 – Listing All the Installed Packages

In this section, you’ll list all the packages installed using pip3. It can be done using the list command with pip3.

pip3 list

It will show you all the list of packages and their dependency packages installed using pip3 as below(Output is trimmed to show the sample).

Package                Version
---------------------- --------------------
Scrapy                 2.4.1
setuptools             45.2.0

Now, you’ll uninstall a package.

Step 6 – Uninstalling a Package With PIP3

In this section, you uninstall a package installed with pip3. uninstall keyword is used along with the package name to uninstall a package.

Use the below command to uninstall a package.

pip3 uninstall package_name

You can uninstall any package by entering the package name in the highlighted place.

Conclusion

In this tutorial, you’ve learned how to install PIP3 on Ubuntu 20.04 and learned how to use Python3-pip on ubuntu 20.04 to install, manage the python packages from the python package index PyPI.

How can I tell what PIP packages are installed?

You can use pip3 list to list all packages installed using pip

How do I install pip?

You can install pip using the command sudo apt install python3-pip

Does python3 come with PIP?

Yes pip comes with python3 since version 3.4

Should I install pip or pip3?

Install Pip if you are using python version older than 3.0 and install pip3 if you want to manage packages relevant for Python Version 3 or later.

What is the difference between pip and pip3?

pip is a package manager to install, upgrade, and uninstall python packages relevant for python versions older than 3.0. whereas pip3 is a package manager to install, upgrade, and uninstall python packages relevant for python versions greater than 3.0

Leave a Comment