= Install pip on Linux

The most popular Python package manager, pip, used to be included in a typical Python install, but lately it's been excluded.
Pip is a useful tool for both running Python scripts and for developing them, and it's easy to install.
There are just two steps to install pip on Linux:

1. Get the installer
+
[source,bash]
----
$ wget https://bootstrap.pypa.io/get-pip.py
----

2. Run the installer
+
[source,bash]
----
$ python3 ./get-pip.py
----

Now that you've install pip, you might want to know more about what it's good for.
Here are some basic used of the `pip` command.

== Install dependencies

When you download a Python script or an application written in Python, it may require specific Python libraries (or "modules", in Python terminology) in order to run.
An application may not bundle support libraries along with its own code because the library isn't maintained by the same developer.
Were it bundled along with unrelated application code, it would be difficult for you to update it independently of the application.

Usually, a developer includes a list of dependencies in a file called `requirements.txt` in the application directory.
If that file exists, you can process it with pip:

[source,bash]
----
$ python3 -m pip install -r requirements.txt
----

If the developer hasn't included a list of dependencies, then it's up to you to read the documentation to learn the what dependencies are required.

If you install software with https://www.redhat.com/sysadmin/install-software-packages-rhel[dnf] or https://www.redhat.com/sysadmin/rhel-tools-flatpak-toolbx#flatpak[Flatpak], you may never have to use pip for this, because those packaging systems install dependencies automatically.

== Install a Python utility

You can use pip for quick installs of useful Python utilities.
For instance, `yamllint` is a must-have command for anyone writing https://www.redhat.com/sysadmin/yaml-beginners[YAML] files, whether it's for Kubernetes or https://www.redhat.com/sysadmin/understanding-yaml-ansible[Ansible] or just for arbitrary config files.
It's one `pip` command away:

[source,bash]
----
$ python3 -m pip install yamllint
----

Or maybe you want to try the https://opensource.com/article/22/7/manage-files-linux-terminal-ranger[Ranger] file manager:

[source,bash]
----
$ python3 -m pip install ranger
----

There's a lot out there for Python, so have a look at http://pypi.org/[Python Package Index (PyPi)] to see what's available.

== See installed packages

To see what Python packages you've already got installed, use the `freeze` command:

[source,bash]
----
$ python3 -m pip freeze
Brlapi==0.8.2
chardet==4.0.0
chrome-gnome-shell==0.0.0
cupshelpers==1.0
dasbus==1.4
dbus-python==1.2.18
gpg==1.15.1
idna==2.10
[...]
----

== Using pip

Pip works well for both users without root access and developers using Python virtual environments.
It's an easy command to use, and it helps you manage your Python install.