Sooheon Kim
Sooheon Kim

Reputation: 105

conda env export --from-history does not track channels

I've installed several packages from different channels (-c rdkit rdkit and -c pytorch pytorch), and I'm only seeing defaults under channels in the output of conda env export --from-history. Is there a flag I'm missing?

I do see a --ignore-channels option, is it that --from-history turns on --ignore-channels by default somehow?

Upvotes: 6

Views: 2418

Answers (1)

merv
merv

Reputation: 76740

Unfortunately, the "explicit spec" doesn't track temporary changes to channels like that. For example, if you installed

conda install -n my_env -c rdkit rdkit

it only treats the rdkit as the explicit spec. Technically, the above doesn't actually specify that rdkit must come from the rdkit channel. Instead, a more accurate interpretation is:

With the channel rdkit prioritized, ensure that my_env has some version of rdkit installed.

I think what you were hoping for (auto-adding of channels to envs) could be a useful behavior, but it is likely something to raise on the GitHub Issues and propose an expected behavior.

Including channel info in explicit specs

In the meantime, one can include channels explicitly in specs, e.g.,

conda install -n my_env rdkit::rdkit

which should result in literally rdkit::rdkit being included in the explicit spec. That is, "install rdkit from the rdkit channel".

Adding channels to an env

To explicitly add a channel to an env, one needs to activate the env and the use the conda config --env. For example,

conda activate my_env
conda config --env --add channels rdkit

Note, there are other options like --prepend and --append if one needs to be more precise about the priorities.

Upvotes: 9

Related Questions