How to Install and Use Pipx on Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

In Python, ensuring package isolation is crucial to prevent conflicts with one another, and to achieve this goal, there are several tools available, including virtualenv, pipenv, and pipx (our topic for today).

Before going more in-depth on pipx, let’s first address the differences among virtualenv, pipenv, and pipx to prevent any confusion and clarify their respective purposes.

  • virtualenv is a tool for creating isolated Python environments where you can install packages and dependencies specific to a particular project.
  • pipenv is a higher-level tool that combines package management (with pip) and virtual environment management (with virtualenv) into a single, user-friendly interface. It aims to simplify dependency management for Python projects.
  • pipx is primarily designed for installing and executing Python applications as if they were standalone command-line tools. It provides a convenient way to isolate and manage these applications in separate environments.

As you grasp their intended purposes, the difference may become clearer. For a sharper understanding, I recommend checking the following use cases:

  • virtualenv typically used when working on multiple Python projects that have different dependencies or when you need complete control over your Python environment.
  • pipenv typically used when you want a streamlined way to manage project-specific dependencies, including both packages and the virtual environment, in a single tool.
  • pipx typically used when you want to install Python programs that you intend to run as command-line tools, keeping them separate from your main Python environment and other projects.

I hope you’ve understood the difference among these virtual isolation tools. Now, let’s understand what exactly pipx is, how to install it, and its usage.

Tutorial Details

Difficulty LevelLow
Root or Sudo PrivilegesYes (for installation)
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Internet RequiredYes

What is Pipx in Python?

Pipx is a fantastic tool that lets you install Python applications in isolated environments, making them globally accessible from your terminal, just like standard Linux commands such as ls, cat, and ps.

Especially helpful when you plan to use specific Python applications, such as β€œnumpy” or β€œneofetchβ€œ, as standalone programs and also within your Python project.

To prevent conflict, an isolated environment is created for each Python application you install via pipx, making sure they don’t make a mess with each other on your main Python setup.

Let’s see how to install and use pipx on your preferred Linux distributions.

How to Install Pipx on Linux

Pipx can be easily installed using β€œpip” without requiring root privileges, but I usually avoid this method due to the multiple configuration steps involved.

I’d prefer you to use one of these commands to install it with the system package manager:

$ sudo apt install pipx                                                                         #For Ubuntu, Debian, Linux Mint
$ sudo dnf install pipx                                                                         #For RHEL, Fedora, AlmaLinux
$ sudo pacman -S python-pipx                                                        #For Arch, Manjaro, EndeavorOS

After completing the installation, execute the following command to add the local bin path to your $PATH environment variable:

$ pipx ensurepath


Adding local bin path to path environment variable

Restart your terminal session now to implement the changes, and then proceed to the next section for instructions on how to use it.

Usage of the Pipx Command

In this section, you’ll learn how to use the pipx command to search, install, list installed packages, update, or remove packages. So, let’s begin with…

Installing Packages

Installing packages with pipx is a breeze – just use the β€œpipx install” command followed by your desired package name, as shown.

$ pipx install cowsay


Installing python packages using pipx

After the installation, you can test that the installed packages are running as a standalone application by using the following command:

$ cowsay -t "Hello, World!"


Running application installed using pipx

When you want to install a particular package version, just specify the desired version followed by β€œ==β€œ, as shown.

$ pipx install numpy==1.25.2


Installing specific version of package via pipx

Listing Installed Packages

The following command will give you a list of all the packages installed via the pipx command:

$ pipx list


list packages installed by pipx

Searching Packages

Pipx lacks an integrated search function due to PyPi API usage restrictions, but this doesn’t mean you can’t do that; you can use pypisearch for searching packages.

To search packages, install pypisearch by running the following command:

$ pipx install pypisearch

Once the installation is complete, pypisearch will be available as a standalone application, and you can easily search for packages by specifying their name as an argument to this command.

$ pypisearch neofetch


Searching for package using pypi command

Upgrading Packages

Like the traditional package manager, pipx allows you to upgrade all the packages at once using the following command:

$ pipx upgrade-all


Upgrade all packages using the pipx

In my system, all packages are currently up-to-date, resulting in no changes. However, in your case, it will start the package upgrade process with the available updates.

Alternatively, you can also upgrade specific package (let’s say β€œcowsayβ€œ) to the latest version by using the following command:

$ pipx upgrade cowsay


Upgrade specific package using the pipx command

Uninstalling Packages

To remove a package, just specify the package name in the β€œpipx uninstall” command, as shown.

$ pipx uninstall numpy


uninstall packages using pipx

How to Remove Pipx from Linux

If you think that this tool isn’t as helpful, you can easily uninstall it from your system using one of the following commands:

Python packages installed with this command will remain accessible as standalone applications from your terminal.
$ sudo apt remove pipx                                                                         #For Ubuntu, Debian, Linux Mint
$ sudo dnf remove pipx                                                                         #For RHEL, Fedora, AlmaLinux
$ sudo pacman -R python-pipx                                                            #For Arch, Manjaro, EndeavorOS

Final Word

I hope you find this article useful, and don’t forget to leave your thoughts or opinions related to this tool, including your queries.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.