How to update an existing Conda environment with a .yml file
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Melt
--
Chapters
00:00 How To Update An Existing Conda Environment With A .Yml File
01:09 Accepted Answer Score 586
01:42 Answer 2 Score 36
02:02 Answer 3 Score 84
02:21 Answer 4 Score 1
02:30 Thank you
--
Full question
https://stackoverflow.com/questions/4235...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #anaconda #conda
#avk47
ACCEPTED ANSWER
Score 586
Try using conda env update:
conda activate myenv
conda env update --file local.yml --prune
--prune uninstalls dependencies which were removed from local.yml, as pointed out in this answer by @Blink.
Attention: if there is a name tag with a name other than that of your environment in local.yml, the command above will create a new environment with that name. To avoid this, use (thanks @NumesSanguis):
conda env update --name myenv --file local.yml --prune
See Updating an environment in Conda User Guide.
ANSWER 2
Score 84
The suggested answer is partially correct. You'll need to add the --prune option to also uninstall packages that were removed from the environment.yml. Correct command:
conda env update -f local.yml --prune
ANSWER 3
Score 36
alkamid's answer is on the right lines, but I have found that Conda fails to install new dependencies if the environment is already active. Deactivating the environment first resolves this:
source deactivate;
conda env update -f whatever.yml;
source activate my_environment_name; # Must be AFTER the conda env update line!
ANSWER 4
Score 1
Recently Conda introduced the option to stack environments, which should solve this problem.