In this guide, you will learn to Use the pip install command 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 to install the pip command on Linux distros and start using it.
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 complete this guide.
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 3 – Install Python Packages with Pip Command on Linux
At this point, you can use the pip command to manage your Python packages. Then, you can list all commands with pip by running the command below:
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. 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. --no-input Disable prompting for input. --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 PEM-encoded CA certificate bundle. If provided, overrides the default. See 'SSL Certificate Verification' in pip documentation for more information. --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. --use-feature <feature> Enable new functionality, that may be backward incompatible. --use-deprecated <feature> Enable deprecated functionality, that will be removed in the future.
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>=22.214.171.124 Downloading XStatic_Font_Awesome-126.96.36.199-py3-none-any.whl (6.5 MB) |████████████████████████████████| 6.5 MB 30.9 MB/s Collecting XStatic-JSEncrypt>=188.8.131.52 Downloading XStatic_JSEncrypt-184.108.40.206-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>=220.127.116.11 ...
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.
At this point, you have learned to Install the latest pip command on Linux distributions and use it to manage your Python packages. 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: