How to install packages from yaml file in Conda


I would like to have one YAML file that could serve to both create virtual environments and (most importantly) as a base for installing packages by conda into the global env. I am trying:

conda install --file ENV.yaml

But it is not working since conda expects pip-like format of the requirements. What command should I execute to install packages from my YAML file globally?

Asked By: maciek



You want the conda-env command instead, specifically

conda env update -n my_env --file ENV.yaml

Read the conda env update --help for details.

If you wish to install this in the base env, then you would use

conda env update -n base --file ENV.yaml

Note that the base env isn’t technically “global”, but rather just the default env as well as where the conda Python package lives. All envs are isolated unless you are either using the --stack flag during activation to override the isolation or have – contra recommended practice – manually manipulated PATH to include an env.

Answered By: merv

If your conda env is already activated, use:

conda env update --file environment.yml

Or update a specific environment without activating it:

conda env update --name envname --file environment.yml
Answered By: Shady Smaoui
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.