I'm running into a minor but annoying issue with conda when installing individual packages from conda-forge. Typically I'd run something like this:
conda install -c conda-forge somepackage
This has the effect of frequently updating other packages using conda-forge: almost always ca-certificates, certifi and openssl; and sometimes major packages like python, numpy etc (all from conda-forge). I suspect these updates are not strictly necessary; those packages get pulled in using some logic along the lines of "in order to install the latest version of somepackage I need python>=3.8 but the current python is 3.7; I can use conda-forge, so I'll get the latest python from conda-forge which is newer than the one in default".
What I would like to accomplish is: install any version of somepackage (not necessarily latest) while installing as little as possible from conda-forge. In particular, if there is a choice between keeping an already installed package and upgrading, I always want to keep; and if there is a choice between default channel and conda-forge, I always want default (even if those choices result in ending up with older versions of the new packages I'm trying to install, and/or their new dependencies - but not if they result in the install being impossible).
How do I accomplish this?
Generally, I endorse the conclusion in @jakub's answer: Define a reasonable global channel priority and try to avoid using ad hoc specifications via the --channel|-c argument.
There are some additional options that may be worth pointing out:
Specify that a particular package should come from a given channel with
conda install conda-forge::somepackage
and this will not change the channel priority.
Explicitly list channel priorities in the install command:
conda install -c defaults -c conda-forge somepackage
which puts defaults with top priority.
Define and manipulate environments through YAML files. YAMLs include a channels section, so you can be explicit about the priority. If you require a new package in the environment, it can be added to the YAML - let's say env.yaml - and that edit can be transferred to the environment with
conda env update -f env.yaml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With