Package installation

PIP

pip is the PyPA recommended tool for installing Python packages. It can be used to install packages from the Python Package Index and other indexes. An overview of the pip command can be found here.

Root or user installation?

When installing a package a used, e.g. $ pip install pipx, pip reports:
Defaulting to user installation because normal site-packages is not writeable
The package will be installed in ~/.local.

When installing a package as root, e.g. $ sudo pip install pipx, pip (as of 21.1) reports a warning: WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Installing as root is considered bad practice. Probably, pip should never be run as root. pip is the installer/manager for Python modules available via PyPI. But it has no idea whatsoever about your package manager (apt, yum, dnf). The result of running pip as root, would be a dirty mix of Python modules installed via yum package management, and pip installed Python modules.

PIPX

pipx is a utility for installing and running Python applications in isolated environments. It’s a great tool for Python developers and users who want to try out different applications without worrying about dependency conflicts (python.land).

pipx is closely related to pip. In fact, it uses pip, but is focused on installing and managing Python packages that can be run from the command line directly as applications.

pipx is installed with pip:
$ pip install --user pipx
$ pipx ensurepath

Note: ensurepath ensures that the application directory is on your $PATH. You may need to restart your terminal for this update to take effect.

Now you can install packages with pipx install and run the package’s applications(s) from anywhere:
$ pipx install PACKAGE
$ PACKAGE_APPLICATION [ARGS]

For example:

$ pipx install cowsay
installed package cowsay 2.0, Python 3.6.2+
These binaries are now globally available
- cowsay
done! ✨ 🌟 ✨
$ cowsay moo