Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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?

+10
−0

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").

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

"package managers install files in system locations" (3 comments)
Post
+0
−0

Dependency conflicts are the problem pipx aims to solve, in the context of installing CLI programs.

When you install a Python package, by default pip will also install their dependent packages so that you don't get ImportErrors when trying to use the package. These dependencies are explicitly configured by the package developer. When you install multiple packages that both have the same dependency, the version of that dependency may complicate things.

For example, say you pip install foo which depends on somedep>=2 and pip decides to install somedep 2.3.1. Then you pip install bar which requires somedep==1.2.3. To ensure that bar works, pip will uninstall somedep 2.3.1 and instead install somedep 1.2.3. Presumably, foo is incompatible with somedep 1.* hence the constraint, so foo will now stop working. At a high level, the problem here is that foo and bar are actually mutually exclusive due to a dependency conflict.

The classic Python solution to dependency conflicts is to create separate virtual environments for foo and for bar. But if the Python package happens to be a CLI tool, your shell will not see the command until you activate the virtual environment.

pipx saves you from this extra step by automatically putting each package in a venv and providing wrapper scripts that run it.

Notably, the python-... packages many distros provide are also vulnerable to the dependency conflict problem. However, they also have more wiggle room for workarounds. For example, they can ignore the dependency versions specified in the package, and provide their own dependencies which have better compatibility. In Python, dependencies are not detected automatically by usage, but specified arbitrarily by the developer. Often, Python developers mistakenly make requirements too general or too specific, which makes it harder to find compatible versions. By ignoring the original developer's (incorrect) version specs, it becomes easier to find a workable set of dependencies. Of course, distro maintainers can also incorporate venvs into python-... packages to get around the problems. All of this and more is feasible when you are creating a distro package, but can be tedious when manually installing packages, hence pipx exists for the latter case.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Just summarizing (1 comment)
Just summarizing
matthewsnyder‭ wrote about 1 year ago

The two previous questions explain the issue in more detail, but I'm adding my own summary in the hopes that it will be useful to other readers.