Configs2026年4月14日·1 分钟阅读

pipx — Install and Run Python CLI Apps in Isolated Environments

pipx installs Python CLI tools (black, poetry, httpie, youtube-dl) into isolated venvs and exposes their commands globally. It eliminates the mess of mixing app dependencies into your system Python.

Introduction

pip install into your system Python is how dependency hell starts. pipx solves it: each CLI tool lives in its own virtualenv, but the entry points are symlinked into a directory on your PATH. You get clean isolation with the convenience of "global" installs.

With over 10,000 GitHub stars, pipx is now the officially recommended way to install Python CLIs — it is bundled with Debian, Ubuntu, Fedora, and Homebrew.

What pipx Does

pipx creates ~/.local/pipx/venvs/<tool> for each installed app and symlinks their scripts into ~/.local/bin. Tools stay isolated (they cannot break each other), are upgradable independently, and can be run once-off with pipx run <tool> without any permanent install.

Architecture Overview

pipx install black
        |
   [Create venv]
   ~/.local/pipx/venvs/black
        |
   [pip install black into venv]
        |
   [Expose entrypoints]
   ~/.local/bin/black --> venv/bin/black
        |
   Shell finds `black` on PATH

pipx run cowsay "hi"  (no install)
        |
   Temporary venv, cached by version, deleted after N days

Self-Hosting & Configuration

pipx install --python python3.11 ansible
pipx install "httpie[all]"
pipx install git+https://github.com/user/mycli.git
pipx install nox
pipx inject nox nox-poetry
pipx run --spec "cookiecutter==2.5.0" cookiecutter gh:audreyr/cookiecutter-pypackage
pipx reinstall-all

Key Features

  • Isolated venvs per app — no dependency conflicts between tools
  • Global-feeling commands — scripts symlinked into PATH
  • One-off runspipx run caches and executes without permanent install
  • Version pinning — install specific versions or from git/PyPI/paths
  • Inject plugins — add deps to a tool's venv without touching the app
  • Upgrade-all — one command updates every installed tool
  • Cross-platform — macOS, Linux, Windows all first-class
  • ensurepath — auto-adds ~/.local/bin to your shell PATH

Comparison with Similar Tools

Feature pipx uv tool pip --user Homebrew apt/pipy
Isolated per tool Yes Yes No (shared) Yes Yes
Python versioning Yes Yes Limited Limited Fixed
One-off run Yes Yes No No No
Speed Good Excellent Fast Moderate Fast
Non-Python tools No No No Yes Yes
Best For Python CLIs Python CLIs + speed Quick installs Native binaries System packages

FAQ

Q: pipx vs pip install --user? A: --user puts every tool's deps into one shared user site-packages — conflicts are inevitable. pipx isolates each tool in its own venv. Always prefer pipx.

Q: pipx vs uv tool — which is better? A: uv tool install is dramatically faster (Rust-based). pipx is more established with wider distro packaging. Both do the same job.

Q: Does pipx work on Windows? A: Yes. It installs .exe shims and pipx ensurepath handles PATH setup.

Q: Can I upgrade just one tool? A: pipx upgrade <tool> upgrades one; pipx upgrade-all upgrades everything.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产