Search code examples
anacondaenvironmentcondaminiconda

Cloning conda "root", if that is the term for your basic initial install


There seem to be other similar questions, but none that seem to be exactly this.

I have created a conda install on a machine. I want to create the exact same install on a 2nd machine. I could export the environment and then create an environment using that exported information. But in all the examples, I'm creating an environment that is a clone of the root. Not a new root that is a clone of the root.

So how to I create a true clone of a conda install? The idea would be

  1. Export the environment of the root on machine 1 conda [something...] > configuration.yml

  2. Install miniconda using Miniconda....sh on machine 2

  3. Recreate the original environment conda [install all the stuff including enironments] configuration.yml

I can't seem to find any explicit instructions for doing this. The closest I found suggests:

conda env export > environment.yml              
conda env update -n root -f environment.yml   

However the first command draws an error:

balter@server:/home/.../Applications$ conda env export > environment.yml


CondaEnvException: Conda Env Exception: 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.


balter@server:/home/.../Applications$ conda -h
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

...
...

One of the posts I found on the interwebs discusses two points that I'm unclear about:

1) Whether pip installs also carry over, and 2) The difference between

conda env create

and

conda create

Solution

  • Conda environments exist as an easy solution to this sort of problem. However, it is possible to do what you ask.

    Step 1: confirm you are in the root environment on the first machine, then export a list of the installed packages:

    $ source activate root
    $ conda list -e > root.yml
    

    Step 2: on the other machine, download and install Miniconda, then install the packages from root.yml:

    $ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
    $ bash Miniconda3-latest-Linux-x86_64.sh
    $ conda install --file root.yml