Learn Python with Talk Python's 270 hours of courses

pipx - Installable, Isolated Python Applications

Episode #371, published Thu, Jun 30, 2022, recorded Wed, Jun 22, 2022

I'm sure you're familiar with package managers for your OS even if you don't use them. On macOS we have Homebrew, Chocolatey on Windows, and apt, yum, and others on Linux. But if you want to install Python applications, you typically have to fallback to managing them with pip. Maybe you install them for your account with the --user flag. But with pipx you get a clean, isolated install for every Python application that you use. And if you distribute Python apps, pipx is a definitely worth considering as a channel.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guests Background

Chad Smith is the creator of pipx, a Python tool for installing and running CLI applications in isolated virtual environments. He has worked in aerospace engineering at Boeing and on projects such as the space shuttle. Later, Chad moved into Python-based tools at a startup funded by Larry Page and currently works at Meta’s Reality Labs, focusing on developer infrastructure and tooling (e.g., debuggers, extensions, and language services). His experience spans scientific computing with MATLAB, building internal tooling at startups, and contributing to Python’s packaging ecosystem.

What to Know If You’re New to Python

If you are just starting out with Python, here are a few essential points to help you get the most from the conversation about pipx and managing Python CLI tools:

  • Use Virtual Environments: Tools like [venv] or [virtualenv] isolate dependencies per project. Pipx internally handles this for single-application installs.
  • Package Installation: Basic pip install might overwrite system-level files or lead to version conflicts. Tools like pipx help avoid that.
  • CLI Entry Points: Python packages offering console commands often rely on “console script entry points.” That’s how something like glances or http (from HTTPie) appears on your terminal.
  • Understand “pipx run”: Beyond installing an app with pipx install, you can do an ephemeral run (pipx run) for a one-off command.

Key Points and Takeaways

  1. Pipx: The Core Idea and Why It Matters
    Pipx makes it easy to install and run Python CLI apps in clean, isolated environments. This ensures that every CLI tool’s dependencies (and versions) are kept separate. For users who just want a tool to “work,” pipx simplifies installation steps that would otherwise involve creating and activating multiple virtual environments. It’s analogous to system-level package managers like Homebrew, apt, or Chocolatey but tailored to Python applications.

  2. Origins of Pipx and the Pipsy Connection
    Chad initially tried Pipsy, a similar tool for installing Python applications in isolated environments, but it was in maintenance mode. This led him to create pipx, adding features like pipx run and an active development community. The transition away from Pipsy highlights the importance of maintainers and contributor engagement in open source.

  3. CLI Entry Points: How Python Tools Become Commands
    Many Python tools define console scripts in their setup or pyproject.toml so that you can type a command like glances or http right on your shell. Pipx looks for these entry points and sym-links them into a location on your PATH. This means once you install, you can run those commands without worrying about Python’s environment details.

  4. pipx run for Ephemeral Usage
    In addition to permanently installing packages, pipx supports a run command that fetches the newest version of a given tool and executes it once—without fully installing it. This is perfect for commands that you only need occasionally, like scaffolding a new project with Cookiecutter.

    • Links and Tools:
      • Cookiecutter
      • Example usage: pipx run cookiecutter <template-repo-url>
  5. Distribution Made Simple: Building Tools for Non-Python Users
    If you develop a Python CLI application and want people outside the Python ecosystem to use it, you can simply instruct them to install pipx. They won’t need to know about venv or python versions. This helps teams or open source projects avoid complex installation instructions (e.g., python -m venv or --user flags with pip).

  6. Handling System Interactions and Virtual Environments
    Chad emphasized that installing tools via sudo pip install or system-level pip can break your OS or other dependencies. By using pipx, each application gets its own virtual environment. This isolation approach also means pipx uninstall <tool> doesn’t affect any other packages or your system-level Python.

  7. Glances and Other Cool Tools
    A good example of pipx’s power is installing Glances, a system monitoring tool written in Python that acts like a more detailed version of top. Rather than installing it globally, pipx can isolate its dependencies and let you run glances command system-wide.

  8. ArgComplete for Shell Completion
    Pipx uses ArgComplete to provide tab completion. It helps generate completions for commands like pipx uninstall <tab> to see a list of installed packages. It also integrates seamlessly with argparse-based CLI tools across shells like Bash and Fish.

  9. PEP 582 “PyPackages” Discussion
    In the episode, Chad mentioned the draft PEP 582, which proposes a __pypackages__ folder for auto-activated virtual environments. While not currently accepted into Python, tools like PDM and PyFlow experiment with this. This underscores ongoing attempts in the Python community to simplify environment management further.

  10. Cross-platform Support and Community Growth
    Pipx aims to work consistently on macOS, Linux, and Windows. Chad notes that Windows support has improved thanks to contributors who tested and validated the workflow. The project’s traction (with 5K+ stars on GitHub) stems from its helpful approach to a long-standing Python packaging challenge.

  1. Utilities You Can Install with Pipx
  • GDB GUI: Chad’s project for debugging with a browser-based interface.
  • PLS: Enhanced ls replacement with color and Git awareness.
  • Cookiecutter: Project scaffolding.
  • HTOP / Glances: System monitoring.

Interesting Quotes and Stories

  • On Pipsy’s Stall: “We were stuck because the maintainer had unsubscribed. We could either fork it or make a new tool.”
  • Regarding Building Tools at a Startup: “I took on the challenge to learn Python, wrote a bunch of tools to automate code generation, and discovered a lot of packaging frustrations.”

Key Definitions and Terms

  • CLI (Command-Line Interface): A program that you run in a terminal or shell via textual commands.
  • Console Script Entry Point: A Python packaging mechanism that automatically creates an executable script for your package when installed.
  • Virtual Environment: An isolated Python environment that keeps dependencies from interfering with each other or the system Python.
  • pipx run: A pipx subcommand to temporarily download and run a Python CLI tool without permanently installing it.

Learning Resources

Here are some excellent resources if you want to deepen your Python skills or better understand packaging and environments:

Overall Takeaway

Pipx addresses a key Python packaging pain point: installing and managing command-line tools in a safe, isolated way. It is both friendly for developers who want to distribute Python CLIs and for users who just want a single terminal command to “make it work.” By bridging the gap between package managers (like pip or conda) and user-level tooling, pipx helps Python developers confidently share their applications with a broader audience, all while keeping dependencies neatly siloed.

Links from the show

Chad Smith: @cs01_software
Pipx: github.com
Entry Points: dev.to
Python Packaging Dashboard: chadsmith.dev
MKDocStrings: mkdocstrings.github.io

gdbgui: github.com
termpair: github.com
httpie: httpie.io
pls (ls-replacement): dhruvkb.github.io
Glances: nicolargo.github.io
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon