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

后端 未结 3 559
失恋的感觉
失恋的感觉 2020-12-02 08:28

How can a pre-existing conda environment be updated with another .yml file. This is extremely helpful when working on projects that have multiple requirement files, i.e.

相关标签:
3条回答
  • 2020-12-02 08:32

    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!
    
    0 讨论(0)
  • 2020-12-02 08:38

    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
    
    0 讨论(0)
  • 2020-12-02 08:48

    Try using conda env update:

    conda activate myenv
    conda env update --file local.yml
    

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

    conda env update --name myenv --file local.yml
    
    0 讨论(0)
提交回复
热议问题