Use pip to Install Python packages on Linux: 2 Easy Steps

In this guide, you will learn to Use pip to Install Python packages on Linux. Pip is a tool that can be used for installing and managing Python packages. It is a simple and easy-to-use tool that you can manage your Python packages. You can follow the steps below on the Orcacore website to install and Use pip to Install Python packages on Linux.

Steps To Use pip to Install Python packages on Linux

Before you start, you must have access to your server as a root or non-root user with sudo privileges. Then, follow the steps below to Use pip to Install Python packages on Linux.

Install Python Packages with Pip Command on Linux

Step 1 – Install the Latest Pip Command for all Linux Users

The pip command line tool is not installed by default on Linux distros. To install the latest pip command which is Pip 3, follow the steps below.

Install pip command on Debian / Ubuntu

On Debian-based distros, you can run the system update and use the command below to install pip:

# sudo apt update
# sudo apt install python3-pip

Install pip command on AlmaLinux / Rocky Linux / RHEL

To install pip on RHEL-based distros, you need to install Epel repo and use the commands below to install pip:

# sudo dnf update
# sudo dnf install epel-release -y
# sudo dnf install python3-pip

Step 2 – Install Python Packages with Pip Command on Linux

In this part of the guide about Use pip to Install Python packages on Linux, you can use the pip command to manage your Python packages. Then, you can list all commands with pip by running the command below:

pip3 help
output
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 dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  cache                       Inspect and manage pip's wheel cache.
  index                       Inspect information available from package indexes.
  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.
...

At this point, you can easily install your Python packages with pip. For example, we want to install the OpenStack Horizon dashboard. To do this, we can use the command below:

pip install horizon
output
Collecting horizon
  Downloading horizon-23.3.0-py3-none-any.whl (5.2 MB)
     |████████████████████████████████| 5.2 MB 2.1 MB/s
Collecting semantic-version>=2.3.1
  Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)
Collecting XStatic-Font-Awesome>=4.7.0.0
  Downloading XStatic_Font_Awesome-6.2.1.1-py3-none-any.whl (6.5 MB)
     |████████████████████████████████| 6.5 MB 30.9 MB/s
Collecting XStatic-JSEncrypt>=2.3.1.1
  Downloading XStatic_JSEncrypt-2.3.1.1-py2.py3-none-any.whl (35 kB)
Requirement already satisfied: requests>=2.25.1 in /usr/lib/python3.9/site-packages (from horizon) (2.25.1)
Collecting XStatic-Angular-FileUpload>=12.0.4.0
...

Pip Search Command is banned by Python

At the current time, if you use the pip search command, you may get the following error:

ERROR: XMLRPC request failed [code: -32500]
RuntimeError: PyPI no longer supports 'pip search' (or XML-RPC search). Please use https://pypi.org/search (via a browser) instead. See https://warehouse.pypa.io/api-reference/xml-rpc.html#deprecated-methods for more information.

The Python developers said that they were experiencing “hundreds of thousands of search calls per hour” and the XML-RPC API had already been determined to be deprecated before this happened.

Note: You can search for the packages directly from the pypi.org site.

Conclusion

At this point, you have learned to Install the latest pip command on Linux distributions and use Use pip to Install Python packages on Linux. You just keep in mind that the Pip search command is deprecated. To resolve this, you can use the original site to search for your desired packages. Hope you enjoy it.

Also, you may be interested in these articles:

Execute Shell Commands in Python with Examples

Run a Python Script in a Linux Docker Container

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!