pip is the package manager for the Python coding language. It can be installed on a Linux system and then used on the command line to download and install Python packages and their requisite dependencies.
This gives developers – as well as users who are just executing Python programs but not developing them – an easy way to download software packages written in Python. It’s available for installation on any major Linux distro and operates in much the same way as a distro’s package manager, which you’re probably already familiar with.
In this guide, we’ll show you how to install pip for Python 2 and Python 3 on various Linux distributions. We’ll also show you basic usage commands for pip, such as installing and removing software packages.
In this tutorial you will learn:
- How to install pip for Python 2 and Python 3 on major Linux distros
- Basic usage commands for pip
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Software||pip, Python 2 or 3|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Install pip on major Linux distros
On many distributions, installing Python 3 (and later versions of Python 2) will usually install pip automatically. So if you already have Python installed, there’s a good chance you have pip as well. If not, it’s easy enough to install with these commands:
$ sudo apt install python3-pip #command for Python 3 $ sudo apt install python-pip #command for Python 2
$ sudo dnf install python3 #command for Python 3 $ sudo dnf install python-pip #command for Python 2
To install pip on CentOS 6 and 7, and older versions of Red Hat:
$ sudo yum install epel-release $ sudo yum install python-pip
$ sudo pacman -S python-pip #command for Python 3 $ sudo pacman -S python2-pip #command for Python 2
To install pip on OpenSUSE:
$ sudo zypper install python3-pip #command for Python 3 $ sudo zypper install python-pip #command for Python 2
Once pip is installed, you can begin using it to install or remove Python packages from your system. Check the section below for some common pip commands.
Basic usage commands for pip
The pip command on your system will either be
pip3 or just
pip. We’re going to use
pip3 in these examples, but just be aware that you may need to change that command for your own system.
To see the version of pip and verify it’s installed on the system:
$ pip3 -V
To install a package:
$ pip3 install package-name
To remove a package:
$ pip3 uninstall package-name
To search for a particular package:
$ pip3 search package-name
To see what packages are installed on your system:
$ pip3 list
To see information about a particular installed package:
$ pip3 show package-name
To access the help menu and see a full list of available pip commands:
$ pip3 help
These are probably all the commands you’ll ever need, but you can check the help menu for a few more, or to get a quick refresher in case you forget one of the commands.
In this guide, we learned how to install pip, the package manager for Python, on all major Linux distributions. We also saw how to use pip to install and remove Python packages, as well as retrieving information about those on our system.