Install and Run Python Applications in Isolated Environments With pipx

pipx is a tool to install and run any of these thousands of application-containing packages in a safe, convenient, and reliable way. In a way, it turns Python Package Index (PyPI) into a big app store for Python applications.

It’s closely related to pip. In fact, it uses pip, but is focused on installing and managing Python packages that can be run from the command line directly as applications.

Best of all, pipx runs with regular user permissions. pipx never needs to run as sudo.

HOW TO INSTALL

Before you try to install pipx, make sure you have Python 3.6+, Pip and venv. But if you’re interested in reading this article, you’re probably already up to date with dependencies.

You can install pipx via pip. First run python3 -m pip install --user pipx and then run python3 -m pipx ensurepath.

macOS users can also install via Homebrew. Just run brew install pipx and then run pipx ensurepath.

On Arch Linux pipx is available IN the official repositories. So you can install it with sudo pacman -S python-pipxand then run pipx ensurepath. I can only assume pipx is also available on other distros. If it isn’t available in the official/community repos, you can always install via pip.

 

 

HOW TO USE

To install a python app run pipx install package. The default binary location for pipx-installed apps is ~/.local/bin. This can be overridden with the environment variable PIPX_BIN_DIR.

pipx’s default virtual environment location is ~/.local/pipx. This can be overridden with the environment variable PIPX_HOME.

To list all the installed apps run pipx list.

 

To uninstall an app run pipx uninstall package or pipx uninstall-all to uninstall all installed packages. If you want to run a python app without actually installing it, you can use pipx run package.

 

To reinstall a package you can run pipx reinstall packageor pipx reinstall-all to reinstall all installed packages.  Also, if you want to upgrade a package you can run pipx upgrade package or run pipx upgrade-allto upgrade all installed packages.

pipx is very well documented, so going into greater detail would be a matter or pointless copy-paste.  You can learn more about it on pipx’s Github page. Also don’t forget to run pipx --help.