r/learnpython • u/MiserableDirt1910 • 18d ago
pip vs pipx
as far as I understand pip just installs the package while pipx installs the executable and creates an environment but why create an environment in the first place? Is it so that when someone else runs the program and there are changes in the package the program might break but an isolated package is protected in the environment?
0
Upvotes
View all comments
Show parent comment
2
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 18d ago
On Linux distros that depend on Python, and Mac OS, you would be correct in that
pipby default prevents you from installing packages to the system Python installation to avoid accidentally breaking things (this can be bypassed with an appropriately named flag;--break-system-packagesIIRC), but it will happily install anything globally to any Python installations you manage yourself.On Windows, there's no restriction because Windows does not depend on Python in any way.
Granted, using virtual environments is generally the best practice, and tools like
uvandpoetrylargely abstract away all this.