Updated at 2022-07-18 09:34

pipx allows running Python packages from command line as applications. It's roughly similar to macOS brew, JavaScript npx, and Linux apt.

Behind the scenes, it installs the package to a virtual environment and figures out what it sets as its setup.entry_points.console_scripts and exposes all of those.

pipx installs executable shortcuts to $HOME/.local/bin by default. pipx ensurepath command makes sure that is set.

Install pipx on Ubuntu:

sudo apt install python3-dev python3-venv python3-pip
python3 -m pip install --user pipx
python3 -m pipx ensurepath
python3 -m pipx completions
# restart shell...

Upgrade pipx in the future:

python3 -m pip install --user --upgrade pipx


pipx install PACKAGE
pipx upgrade PACKAGE
pipx uninstall PACKAGE

You can also use local packages:

pipx install /home/projects/my-project

Usage with pyenv:

pyenv versions --bare
pyenv shell 3.10.2
pipx install PACKAGE --python `which python`