Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on What is the point of pipx?
Parent
What is the point of pipx?
Background
Many Python programs now recommend installing with pipx, and there is a sense that you shouldn't install with pip anymore, you should use tools like pipx.
Main Question
However, what does pipx actually do that makes it such a preferred alternative to pip?
Thoughts
I checked their docs and what I found doesn't really make sense. In sum:
- pipx is described as a package manager, but package managers install files in system locations whereas pipx installs them in user locations. Also, package managers already have
python-...
packages where it makes sense. - It mentions that unlike pip, it is specifically for CLI apps. But what exactly does pip not do? AFAIK executable packages just have a wrapper script in
~/.local/bin/
that calls them. This doesn't seem worth a whole program. - It talks about PyPi as an "app store", which sounds weird. Yes, people can and do distribute on PyPi, but there are major differences which pipx hardly closes.
I do see that it mentions isolating envs. I can see how it is not straightforward with pip to install each CLI app in a venv, but also make it available in PATH. So is that all pipx is, CLI apps in venv? This seems like a rather inefficient way to handle packaging (see also "static link everything").
Post
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
matthewsnyder | (no comment) | Sep 5, 2023 at 15:20 |
They are tools for different audiences. pipx
does not replace pip
.
In some more detail, pip
answers the question "As a Python developer, how can I install Python packages and their dependencies" whereas pipx
answers the question "As a user, how can I conveniently install a tool which is available via PyPi, without learning anything about Python, and without ending up in a situation where two packages I installed have trouble coexisting because they have conflicting or otherwise incompatible dependencies?"
Seen from this angle, it's pretty clear that the use cases are different.
pipx
takes care to encapsulate each installation so that, behind the scenes, the installation effectively has its own virtual environment which gets activated when you run a pipx
-installed command. Thus, any dependencies pipx
installs are specific to, and separated from, any other Python packages installed elsewhere on your system somehow.
Even as a Python developer, I have some tools that I install because they are convenient to have available on my system, not particularly because they help me with Python or as a developer. The CLI for Amazon AWS is a good example.
Also, on shared servers, I can install tools like ruff
without messing with the system or breaking anything for other users.
Any instructions which recommend installation with pipx
, then, are meant for consumers of the utility package. The instructions basically imply, "if you know how to use pip
, and prefer to use that for your use case (for example, to install this package as a dependency for a Python project of your own), by all means use pip
instead if you like."
Obviously, pipx
only makes sense for packages which are useful as a standalone CLI utility. For your Python development needs, pip
remains the recommended installation tool, and the only one which makes sense for a library you want to use from your own Python code, directly or indirectly.
1 comment thread