Prevent Conda From Automatically Downgrading Python Package
Solution 1:
Specify Minimum Version
Conda is sufficiently powerful to parse minimum versions, and it remembers that they've been specified. If you would prefer 0.9 as the minimum, then you just need to say so with
conda install 'pandas-datareader>=0.9'
or
conda install pandas-datareader[version='>=0.9']
Once you've run this, it will be added into your explicit specifications, and that should lock in at least that version of pandas-datareader
, including in subsequent conda update --all
runs. This answer has a fuller description of Conda's MatchSpec system, which covers the scope of what can be specified.
Channel Specifications
Although this isn't what OP effectively wants, it may be worth elaborating why the channel switching happened and how a channel can also be explicitly specified.
The --channel|-c
flag only adds (and prioritizes) a channel during the command it is used with. It does not tell Conda that a particular package should come from that channel. Hence, since OP likely has conda-forge prioritized over defaults in their global/user configuration (see conda config --show channels
), running conda update --all
will simply switch back to whatever the most recently uploaded build is.
To explicitly indicate that a package should come from a channel, one should instead use
conda install anaconda::pandas-datareader
This will then add anaconda::pandas-datareader
into the explicit specifications, and that should lock in the fact that one expects pandas-datareader
to come from the anaconda channel.
Package Pinning
Otherwise, package pinning could be another option.
[1] One can check explicit specifications with conda env export --from-history
.
[2] Be aware that some flags may override explicit specifications without warning, such as --update-deps
.
Post a Comment for "Prevent Conda From Automatically Downgrading Python Package"