pip and venvs on Debian

Roel Schroeven roel at roelschroeven.net
Tue May 21 04:03:09 EDT 2024


Op 20/05/2024 om 23:48 schreef Akkana Peck via Python-list:
> Every so often I need to regenerate it (like when Debian updates the system Python version) but that's easy to do: I don't try to duplicate what's installed there, I just delete the old venv, create a new one and then pip install packages as needed.
>
> I know this isn't the usual pythonista model of "you should have a zillion different venvs, one for each program you use, and never use system Python packages", but it works well for me: my pip installed packages are all in a predictable place, and I get security updates for all the software Debian *does* package. That's my biggest beef with pip, the lack of an easy way to update everything at once, and it's the reason I prefer Debian packages when available.
If you have a requirements.txt file with all packages you want, I think 
you can do pip -install --upgrade -r requirements.txt to update them 
all. That only works if you don't specify exact versions in the 
requirements.txt file, so don't use the output of pip freeze to generate 
that requirements file. Just create it yourself: it's a simple text file 
with one package per line. Also I prefer not to include dependencies in 
it for use cases like this (it's another story for packaging, where it 
can be useful or requirements.txt to mirror your exact environment with 
dependencies and specific versions).

Having such a requirements.txt file also makes it easier to install all 
the packages again after you re-create your venv.

-- 
"I love science, and it pains me to think that to so many are terrified
of the subject or feel that choosing science means you cannot also
choose compassion, or the arts, or be awed by nature. Science is not
meant to cure us of mystery, but to reinvent and reinvigorate it."
         -- Robert Sapolsky



More information about the Python-list mailing list