Yes, you should use a Python venv in a container like docker
Yes, you should use a Python venv in a container like docker
Brought to you by "/r/python answers are so bad I had to write this"
Yes, you should use a Python venv in a container like docker
Brought to you by "/r/python answers are so bad I had to write this"
Soon, you won't have a choice because major distros are adopting PEP 668. This will make pip install fail in the default system Python and show an error telling you to use a virtual environment.
Well, if this is true then why bother convincing people ;)
So ... if I want to use a python module like, for example, mcstatus in a live shell for convenience I first need to create a venv, activate it, install the package and then use it? And then either have dozens of venvs somewhere or remake them every time?
you can use UV for this use case: https://docs.astral.sh/uv/guides/tools
Use pipx or uv --run
Distrobox?
Even with PEP 668, you can still use pip --break-system-packages
I hate this hand-holding. Certainly use venvs for dev projects but allow system-wide installations for those that want it. OSS has always been about giving you enough rope to hang yourself.
then they come after our guns, but spoons are always magically safe
To all the fat slob system wide installation cock blocking PR submitters, i say,
Ban spoons!
Shooting ourselves in the foot is a G'd given right! /nosarc
Couldn't have said it better. 😆
What really annoys me is they purposely broke per-user and local installation. Fine, system wise installation isn't a good idea when it's already managed by another package manager, but user installation is my domain.
The reason they did this is because a package installed by the user can be active when a system tool is called and break the system tool. The distro developers went "Oh, we should force all user code into venvs so that our code is safe".
Completely and utterly backwards. The protected code needs to be inside the defensive wall. The user should be allowed to do anything in the knowledge that they can't inadvertently change the OS. When a system tool is called it should only have system libraries on it's Python Path.
You still have the option to choose not to use a venv and risk breaking your user space.
The changes make this harder to do it by accident by encouraging use of a venv. Part of the problem is that pip install --user
is not exactly in the user space and may in fact break system packages, and as you wrote, the user shouldn't be able to inadvertently change the OS.
Which you can still do. That said, the "correct" and less problematic way of installing packages should be easier than the alternative.
You already are forced to use a venv, but I fucking hate pip and some projects don't work in venv I don't know why it just doesn't and it sucks
That's the thing, if everybody is forced to use a venv, those projects will either fix their shit or lose all of their userbase.
So these package maintainers are harboring magical charms and voodoo dolls which us lowly plebs just don't know about?
If these guys are so awesome, shouldn't we be plying them with coke and blow and keep 'em working resolving our dependency resolution issues?
They do have the secret sauce and just holding it back from the rest of us
Don't wanna be that guy who gaslights you.
If you are having issues, should be pointing us at a repo
System-wide installation as it was implemented should stay in the past. I like pixi's (Conda alternative) approach here, where each system dependency lives in its own virtual bubble, so recreating and porting this software is a breeze.
But if all you use can stay in a venv, just use one.
I was about to go man systemd-wide
Same thing said another way, be open to using more than one venv
@norambna Good points! 👍🏻 especially since conflict resolution in PIP sucks and it’ll happily install incompatible packages
pip is great! It lets ya know when there are dependency conflicts.
Up to us to learn how to deal with resolving dependency conflicts.
There are those who attend the whining parade down main street.
There are the very very few who write a package to resolve these issues.
How will this affect command-line tools like azure-cli installed in a container image that can be installed with pip? Will we be forced to append the venv to $PATH?
We need AA meetings
Hello!
My name is Billy Joe Jim Bob
Hello Billy!
I haven't had a dependency conflict for the past 3 hours. The sleeping problems haven't gone away. As i feel my eye lids drupe, keep thinking about each of my packages and imagining where will the next unresolvable dependency conflicts emerge.
Then i wake up covered in sweat.
Can't keep going on like this. Thank you for listening
Thank you for sharing Billy!
I'd you have full ci/cd then it's unnecessary