How to install packages from yaml file in Conda

maciek picture maciek · Oct 7, 2019 · Viewed 12.7k times · Source

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?

Answer

merv picture merv · Oct 7, 2019

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.