Last updated on January 22, 2020
In this post, we will learn how to use pipx. Specifically, we will learn how to use pipx to install Python packages. We will learn how to install pipx, use pipx to install packages, how to run Python packages from a temporary environment, how to uninstall packages, and upgrade packages using pipx.
What is Pipx?
Pipx is a Python package management tool much like pip. This tool, on the other hand, enables us to install and run Python packages. What is really neat with pipx is that it installs the Python packages in an isolated virtual environment (see also pipenv). It will also let us run the Python packages without activating the environment. This means that we can install multiple versions of a Python package and still have access to it. Moreover, pipx enables us to run a Python package from a temporary environment.
How to Install Pipx
Now, we need to have Python 3.6+, pip and venv installed before installing pipx. To install pipx we just run pip:
pip install –user pipx
How to Install a Python Package Using Pipx
In this section, we are going to learn how to install Python packages using pipx. More specifically, we are going to install the latest version of the command line tool dadjokes-cli.
Installing a Python Package with Pipx
Now, we are ready to install a package with pipx. It’s very easy and we just type the following command:
pipx install dadjokes-cli
Now, when we have installed dadjokes we can run it from the terminal, or command prompt (windows). If we are running a Windows Machine we type the following in the command prompt.
Note, if we were running Linux, for example, we’d, of course, skip the “.exe”-part.
Pipx list: See all Installed Python Packages
Now, if we need to see all the installed Python packages (i.e., installed with pipx) we can type
This will give us a list of of all the Python packages we have installed using pipx.
Using Pipx to Run a Python App
Now, we cannot use pipx to run the dadjokes-cli app but, as can be seen in the example from their homepage, we can run a Python app. If we use the same example and run pycowsay:
pipx run pycowsay.
How to Uninstall Python Packages with Pipx
Now, if we want to uninstall a Python package we have installed using Pipx we can just type
pipx uninstall dadjokes-cli.
Furthermore, it is also possible to uninstall all packages by typing
Upgrading Python Packages with Pipx
Finally, we are going to learn how to upgrade packages we have installed using pipx. This is very simple. If we want to upgrade dadjokes-cli we can run the following command:
pipx upgrade dadjokes-cli
Of course, if we want to upgrade all Python packages we have installed we can just run
In this post, we have learned how to install Python packages using pipx. This tool makes it possible for us to install packages in isolated virtual environments. This way, our system may not break down as if we installed the Python packages using pip. Furthermore, we have also learned how to uninstall, and upgrade packages using pipx.