How to update an existing Conda environment with a .yml file

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.

Leave a Comment