pipx Tool: 7 Essential Commands for Python Application Management

What Is the pipx Tool?

The pipx tool installs and runs Python applications in isolated environments. If you have ever used pip install --user to install a command-line tool like black, poetry, or httpie, you probably ran into dependency conflicts. pipx fixes that by giving each application its own virtual environment while still making its command available on your PATH.

I started using pipx a few years ago when I got tired of Python package conflicts breaking my global tools. It has been one of those changes I wish I made sooner. Once you install it, you barely think about it. It just works. Pair it with tools like fzf for fuzzy searching and bat for reading files and your terminal becomes a much more capable environment.

Installing the pipx Tool on Linux

You can install pipx using your package manager, which is the cleanest approach. On Debian or Ubuntu, it is:

sudo apt update
sudo apt install pipx
pipx ensurepath

The ensurepath step is important. It adds the pipx binary directory to your shell configuration file so you can run installed applications from anywhere. If you use Fedora, the command is sudo dnf install pipx. On Arch, it is sudo pacman -S python-pipx.

You can also install pipx through pip itself, though I recommend the package manager route for cleaner upgrades:

python3 -m pip install --user pipx
python3 -m pipx ensurepath

After installation, restart your terminal or run source ~/.bashrc to load the PATH changes.

1. Installing Python Applications with the pipx Tool

The most common thing you will do with pipx is install a Python application. The command is simple:

pipx install PACKAGE_NAME

For example, to install black, the code formatter:

pipx install black

Pipx creates a dedicated virtual environment in ~/.local/pipx/venvs/, installs the package there, and then symlinks the executable into ~/.local/bin/. pipx handles all of this automatically. You never need to activate that virtual environment or manage it yourself.

I installed six Python tools through pipx on my work machine and they have been running for months without a single conflict.

2. Running Applications Without Installing

Sometimes you just want to try a tool once. You do not want to install it, use it, and then remember to uninstall it. The pipx run command handles this:

pipx run pycowsay "Hello from pipx"

Pipx downloads the package, creates a temporary virtual environment, runs the command, and cleans up. The pipx tool caches the environment so subsequent runs are fast. This is perfect for one-off tasks where you want a tool without committing to it.

Another example: need to serve a directory over HTTP quickly?

pipx run httpie https://api.github.com

No installation, no cleanup. Just works.

3. Listing and Managing Installed Applications

To see everything installed through pipx:

pipx list

This shows each package, its version, the Python version it uses, and the path to its virtual environment. The pipx tool displays this in a readable format so you know what you have and where it lives.

To upgrade a specific package:

pipx upgrade black

Or upgrade everything at once:

pipx upgrade-all

Need to remove something? Simple:

pipx uninstall black

That removes the virtual environment and the symlink in one clean operation.

4. Injecting Additional Packages into an Environment

Some tools support plugins. If you installed black and want to add the black-magic plugin, you can inject it into black’s existing virtual environment:

pipx inject black black-magic

The pipx tool installs the extra package into the same isolated environment without affecting anything else on your system. This keeps plugin dependencies separated from your main Python installation.

5. Using pipx with Different Python Versions

Pipx defaults to the Python version that was used to install pipx itself. If you need to install a tool under a different Python version:

pipx install --python python3.12 PACKAGE_NAME

This is useful when you run tools that need specific Python versions or when you are testing compatibility. The pipx tool creates the virtual environment using whichever Python interpreter you specify.

6. Reinstalling All Packages After a Python Upgrade

When you upgrade your system Python, the virtual environments pipx created may break because they reference the old interpreter path. Pipx handles this with:

pipx reinstall-all

This rebuilds every virtual environment from scratch using your current Python. I ran this after upgrading from Python 3.11 to 3.12 on my server. It took about thirty seconds and everything worked again.

7. Pinning Package Versions

Sometimes you need a specific version of a tool for compatibility or testing. The pipx tool lets you pin versions:

pipx install black==23.12.0

When you run pipx upgrade-all, pinned packages are skipped. Only unpinned packages get upgraded. This gives you control over which tools stay stable and which ones follow the latest release.

Why the pipx Tool Beats pip install –user

The old way of installing Python tools was pip install --user. This works until two different tools need different versions of the same dependency. When that happens, you get the dreaded dependency conflict that can break both tools.

Pipx eliminates this entirely. Each tool gets its own virtual environment with its own set of dependencies. The pipx tool isolates them from each other and from your system Python. No more version conflicts, no more broken tools after a system update.

Another advantage: uninstalling is fully clean. When you pip uninstall a –user package, leftover files sometimes linger. Pipx removes everything when you uninstall the virtual environment and the symlink. Nothing is left behind. This pairs well with other tools that clean up your terminal workflow, like ripgrep for fast file searching.

Common pipx Workflows I Use Daily

Here is how pipx fits into my actual daily routine:

  • poetry for Python project management, installed via pipx install poetry
  • black for code formatting, installed via pipx
  • httpie for API testing, used on demand with pipx run httpie
  • cookiecutter for project scaffolding, installed via pipx

Every one of these runs from its own isolated environment. I update them individually with pipx upgrade when a new version drops.

One tip: run pipx upgrade-all once a week to keep everything current. I have this in a weekly cron job. It takes a few seconds and keeps my tools running smoothly.

If you are still using pip install --user for command-line tools, try the pipx tool. It is a small change that removes a whole category of headaches. Check out the pipx GitHub repository for more details, or see the Python Packaging guide for the official documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts