'Taking a conda environment to another PC efficiently

This may be a noob question, I am new to using Conda environments. I am looking for some advice on how to tackle the following workflow in the best way.

I have both a work desktop and a desktop at home. I want to be able to, at the end of the day, take my work environment home.

Note: I work in Ubuntu on subsystems for windows

Say I start a project from scratch. I currently use the following workflow:

  1. I create a conda environment.

    conda create --name my_new_project python=3.10

  2. activate my workspace.

    conda activate my_new_project

  3. I install python packages I need:

    conda install -c conda-forge opencv etc...

  4. At the end of the day I want to copy that environment and take it to another PC, so I do the following:

    conda env export --f my_new_project.yml

  5. Finally on my home PC I do

    conda env create --file my_new_project.yml

This works but requires me to make a new environment every time I switch PC. Is there a way to load the differences between the two conda environments and only add the new packages? Or is there another better way to tackle this?



Solution 1:[1]

There's no need to create a new environment every time. You only do that once and then update the existing environment, i.e. use the following as step 5:

conda env update -f dependencies.yml

I also suggest you to put your code, including the dependencies file, into version control if you aren't doing that already. Then, getting up to speed with your project on a different computer will only require two steps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jan Wilamowski