From: pypa/pip#9187 (comment)
could there be an easy option that forbides pip-21.2.1 to downgrade any already installed package (like specifying the existing packages version as a minimal constraint
>=
) ?
@stonebig if you still have your pip cache populated, there is a way to achieve it without spamming the pypi registry: you can use the output of pip freeze
and feed it to your pip command with an additional -r
(it can be used multiple times):
pip freeze | sed 's/==/>=/' >> ./constraints.txt
pip install <some-new-package> -r ./constraints.txt
As all of constraints.txt is already satisfied, nothing will be re-installed unless needed. And given a populated pip cache, it also wont consume much bandwidth.
Whether it actually speeds things up (or causes panic instead), I don't know.
If you want to be even more strict (don't down NOR upgrade anything in your env), you can leave out the sed
replace above and use pip's --constraint
flag instead of -r
. Constraints passed here will not be installed (the file can contain any set of packages also unrelated to your install), but it will force conflicts faster.
Hope that helps!