Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do you update a conda environment from yml?

Update Conda Environments Using a YAML File Once you have created a conda environment, you can update it anytime by first activating the environment and then running the conda env update command.

How do I add a package to an existing conda environment?

You can install a conda package also without activating the environment. Just use conda install -n <env_name> <package> or conda install -p <path/to/env> <package> . Show activity on this post. If you want to install a specific package inside a specific conda environment, you can use the following command.

What is environment yml in conda?

environment.yml files have a specific syntax (e.g. for env name, source channels, packages) e.g. conda env create --file environment.yml. some flags available with conda create are not available with conda env create , such as --strict-channel-priority , which may result in some confusion.


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.

Or without the need to activate the environment (thanks @NumesSanguis):

conda env update --name myenv --file local.yml --prune

See Updating an environment in Conda User Guide.


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

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!