skaarfacee
skaarfacee

Reputation: 321

What is the difference between pipx and using pip install inside a virtual environment?

I recently used pipx to install a package (That was the recommended install approach for the package). I installed using pip in a virtual environment. I was with the assumption that pipx is in that environment, and then pipx would install the package in the same environment. However, pipx created a environment folder and installed the package there. I had to add the PATH into in order to use that package. This led me to think what the difference between pipx and using pip install inside a virtual environment.

Isn't using pip from the virtual environment more convenient to install the package?

Upvotes: 10

Views: 13049

Answers (1)

Kinuax
Kinuax

Reputation: 410

pipx can be seen as an automation tool or a wrapper around pip and venv to mainly manage isolated virtual environments, install Python cli applications and expose their binaries.

An important difference with pip is that pipx is focused on packages that have at least one entry point to be called from the terminal and does not allow to import and use libraries. For instance, this is not supported:

pipx install <library>
python -c "import <library>"

Another interesting feature of pipx is that it can expose apps to end users that are unfamiliar with Python and virtual environments but are interested in some tool implemented in Python, so after pipx install <tool> they can just type tool and use it right away seamlessly. This way pipx works as a package manager, similar to apt, dnf, brew, and others.

Upvotes: 15

Related Questions