How to install packages from yaml file in Conda

35,133

Solution 1

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.

Solution 2

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
Share:
35,133

Related videos on Youtube

maciek
Author by

maciek

Updated on July 09, 2022

Comments

  • maciek
    maciek almost 2 years

    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?

  • maciek
    maciek over 4 years
    This does not work, I get: CondaEnvException: Unable to determine environment Please re-run this command with one of the following options: * Provide an environment name via --name or -n * Re-run this command inside an activated conda environment.
  • maciek
    maciek over 4 years
    I don't think you understood me. I want to install packages GLOBALLY. Instead of writing conda install X; conda install Y; conda install Z I just want to provide one file with specifications
  • maciek
    maciek over 4 years
    Thank you very much, could you please update our answer with "--name base" and a link to explanation that the general conda environment is called base (so that I can accept it)? This would well serve for further generations.
  • merv
    merv over 4 years
    @maciek I updated it, but I'll also caution that your base env is where Conda lives and the less you manipulate it the more stable it will be. I would especially avoid installing anything with pip in there.
  • salotz
    salotz over 4 years
    One observation: the output from conda is a bit weird and doesn't actually tell you what it is installing so it can be a bit confusing because that is what I would expect.
  • merv
    merv over 4 years
    @salotz yeah, the conda-env tool is a bit underdeveloped compared to the main tool. For instance, it also doesn't give you a chance to inspect the proposed transactions and choose to accept or reject them.