12

I have anaconda environment called 'juldou_learning'.

I downloaded from Git a project with environment.yml inside.

I don't want to create new environment with environment.yml like:

conda env create -f environment.yml

but, only install packages to juldou_learning which are present in environment.yml file.

following does not work:

(juldou_learning) MBPuzivlaJulius:juldou_learning juldou$ conda install --file environment.yml 

CondaValueError: could not parse 'name: juldou_learning' in: environment.yml
marianoju
  • 334
  • 4
  • 15
Július Marko
  • 1,196
  • 5
  • 15
  • 37
  • 1
    Does `conda install --file environment.yml` work? https://conda.io/docs/commands/conda-install.html You might need to activate your environment first. – darthbith Aug 04 '17 at 19:21
  • 1
    What about `conda env update --file environment.yml` https://conda.io/docs/commands/env/conda-env-update.html – darthbith Aug 04 '17 at 21:24
  • 1
    Possible duplicate of [How to update an existing Conda environment with a .yml file](https://stackoverflow.com/questions/42352841/how-to-update-an-existing-conda-environment-with-a-yml-file) – darthbith Feb 04 '19 at 16:07

2 Answers2

15

You can use the env command

conda env update --file environment.yml

You may need to activate the environment into which the packages are going to be installed first.

darthbith
  • 18,484
  • 9
  • 60
  • 76
  • 6
    Unfortunately if you have an environment name in `environment.yml` the update/install will happen to that named environment. But you can easily fix that with `conda env update --name env_name --file environment.yml` – hobs Jan 13 '19 at 03:47
11

Like @darthbith said, use conda-env update, but don't forget to name the environment you want to install the packages into. If the environment.yml file contains an environment name, your packages will get installed there, regardless of which environment is currently activated. Here's how to name the target environment name:

conda env update --name environment_name --file environment.yml

Of course there are short argument names for --name and --file. To install the environment.yml packages in my base conda environment (the one that's activated if you haven't activated any others) I had to:

conda env update -n base -f environment.yml
hobs
  • 18,473
  • 10
  • 83
  • 106