This article is part of in the series
Published: Thursday 13th March 2025

Managing Python applications and their dependencies has always been a challenge. System-wide installations can lead to conflicts, while virtual environments add complexity when you just want to use a tool. Python pipx is a tool designed to install and run Python applications in isolated environments, combining the simplicity of global commands with the safety of isolation.

The Python Packaging Problem

Python developers frequently face a dilemma when installing command-line applications:

  1. Install globally with pip: This makes tools immediately available but can cause dependency conflicts.
  2. Use virtual environments: This isolates dependencies but requires activating environments to access tools.

Both approaches have drawbacks, especially for command-line utilities that you want available system-wide without conflicts. pipx was created specifically to solve this problem.

What is pipx?

Python pipx is a tool that allows you to install and run Python applications in isolated environments. It combines the convenience of global accessibility with the safety of isolation.

When you install a Python application using pipx, it:

  1. Creates a dedicated virtual environment for that application
  2. Installs the application and its dependencies in that environment
  3. Makes the application available in your PATH

This approach means you can run Python applications as if they were installed globally, but without risking dependency conflicts between different tools.

Installation

Getting started with Python pipx is straightforward:

Using macOS:

brew install pipx
pipx ensurepath

Linux:

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

On Windows:

python -m pip install --user pipx
python -m pipx ensurepath

The ensurepath command adds the necessary directories to your PATH, ensuring that applications installed with pipx are accessible.

Core Features and Usage

Installing Applications

Installing a Python application with pipx is simple:

pipx install package-name

For example, to install the popular HTTP client httpie:

pipx install httpie

After installation, you can run the application directly:

http --version

Listing Installed Applications

To see what applications you've installed:

pipx list

This command shows all applications installed via pipx, along with their versions and any injected packages (more on this later).

Upgrading Applications

Keeping your tools up-to-date is easy:

# Upgrade a specific application
pipx upgrade black

# Upgrade all applications
pipx upgrade-all

Uninstalling Applications

Removing applications is equally straightforward:

pipx uninstall black

This completely removes the application and its isolated environment.

Running Applications Without Installation

One of pipx's most powerful features is the ability to run applications without installing them permanently:

pipx run cowsay "Hello World!"

This command creates a temporary environment, installs the application, runs it, and then cleans up afterward. It's perfect for tools you only need occasionally or for trying out new applications without committing to an installation.

Advanced Features

Injecting Dependencies

Sometimes you want to add additional packages to an installed application. pipx inject allows this:

# Add pytest-cov to the pytest environment
pipx inject pytest pytest-cov

This installs pytest-cov into the same virtual environment as pytest, making its functionality available when you run pytest.

Running with Specific Package Versions

You can specify exact versions when running applications:

pipx run --spec="black==21.5b2" black myfile.py

This is useful for testing how different versions of a tool might process your files.

Installing from Git

pipx also supports installation directly from Git repositories:

pipx install git+https://github.com/psf/black.git

This allows you to use development versions or forks of applications.

Using Alternative Python Versions

By default, pipx uses the Python interpreter that was used to install it. However, you can specify a different interpreter:

pipx install --python python3.9 package-name

This is invaluable when you need to run tools with specific Python version requirements.

Real-World Use Cases

For Developers

Developers can use pipx to install development tools without polluting their global Python environment:

pipx install black       # Code formatter
pipx install mypy        # Static type checker
pipx install pylint      # Linter
pipx install pytest      # Testing framework
pipx install poetry      # Dependency management
pipx install cookiecutter # Project templating

Each tool lives in its own environment but is accessible globally, creating a clean, conflict-free development setup.

For DevOps Engineers

DevOps professionals can use pipx to manage infrastructure-as-code and cloud tools:

pipx install ansible     # Configuration management
pipx install awscli      # AWS command-line interface
pipx install azure-cli   # Azure command-line interface
pipx install terraform-compliance # Terraform testing

This approach ensures these tools don't interfere with each other, even when they have conflicting dependency requirements.

For Data Scientists

Data scientists can isolate their command-line analytical tools:

pipx install datasette   # Explore and publish data
pipx install csvkit      # Command-line CSV manipulation
pipx install jupyter     # Notebook environment

Comparison with Alternatives

pipx vs. pip

While pip is the standard package installer for Python, it installs packages globally by default, which can lead to dependency conflicts. pipx resolves this by creating isolated environments.

pipx vs. conda

Conda is a powerful package manager for multiple languages, but it's more complex and focused on full environments. pipx is Python-specific and focuses on making applications available globally in an isolated way.

pipx vs. brew/apt

System package managers like Homebrew or apt install applications system-wide, often with their own Python interpreters. pipx uses your Python installation but keeps applications isolated from each other.

pipx vs. Docker

Docker provides complete isolation through containerization but has more overhead. pipx offers a lighter-weight solution specifically designed for Python applications.

Best Practices and Tips

When to Use pipx

pipx is ideal for:

  • Command-line applications you want to use across projects
  • Tools with complex dependencies that might conflict
  • Utilities you need available regardless of your current virtual environment

However, it's not designed for:

  • Libraries that you import in your code (use pip with virtual environments)
  • Applications that aren't Python-based (use system package managers)

Combining with Other Tools

Python pipx works well alongside other Python tools:

  • Use virtualenv or venv for project-specific dependencies
  • Use pipx for global command-line tools
  • Use pip inside virtual environments for libraries

Automating Installation

You can script python pipx installations for setting up new development environments:

#!/bin/bash
# Install common development tools
pipx install black
pipx install mypy
pipx install pylint
pipx install pytest
pipx install pre-commit

Troubleshooting Common Issues

If you encounter problems:

  1. Command not found: Run pipx ensurepath and restart your shell
  2. Dependency conflicts: Use pipx inject to add additional packages
  3. Version issues: Specify the Python version with --python

Under the Hood

Understanding how pipx works can help you use it more effectively:

  1. It creates virtual environments in ~/.local/pipx/venvs/
  2. It symlinks executables to ~/.local/bin/ (or equivalent on Windows)
  3. It manages metadata about installations for updates and management

This architecture keeps applications isolated while making them globally accessible.

Recent Developments and Future Direction

As of early 2025, pipx continues to evolve with improvements including:

  • Better integration with Python packaging standards
  • Enhanced support for Python applications with native dependencies
  • Improved performance when running applications without installation
  • Additional options for environment reuse and sharing

The tool maintains its focus on simplicity and user experience while expanding its capabilities.

Summary

pipx elegantly solves a common problem in the Python ecosystem—how to make applications globally available without risking dependency conflicts. By creating isolated environments  while exposing commands globally, it provides the best of both worlds.

Whether you're a developer installing coding tools, a system administrator managing automation scripts, or a data scientist working with analytical utilities, pipx offers a cleaner, safer way to manage Python applications.

By adopting pipx as part of your Python workflow, you can:

  1. Avoid dependency conflicts between different applications
  2. Keep your global Python environment clean
  3. Easily update and manage command-line tools
  4. Try new applications without commitment
  5. Ensure consistent behavior across different projects

More Articles from Unixmen

How To Install OpenCV using pip: A Step by Step Guide For Beginners

How To Use Pip (Simple Guide To Install, Update, Uninstall Packages)