Clone & Export

Cloning an existing conda virtual environment

There are occasions where you’d want to install extra packages to an already existing virtual environment. However, you may not have the necessary permissions to do so, your best bet would be to create a new environment.

Rather than recreating the entire virtual environment which includes re-downloading the required dependencies, you can simply clone the existing virtual environment and activate it. Then, you can install your own packages to it so as to save you some time as well as cutting-off the extra work.


conda --name <your_custom_environment_name> --clone

$ conda create --name myproject --clone my_env

The my_env is the name of the already existing environment you intend cloning and myproject is the name of the new environment you are cloning into.

Exporting Your Environment as YAML File

Why export the environment as a YAML file?

By exporting the environment as a YAML file, you can rebuild the exact same environment.

Also, you can easily keep track of all the libraries used and their exact versions.

How to export?

You can export the current state of the environment to a YAML file using:

$ conda env export > current_env.yml

Then, you will find current_env.yml file in your current working directory.

Use the YAML file to reproduce the environment:

With the YAML file, you can easily reproduce your virtual environment.

See Create & Use section 3. Create the environment: (1) Pre-defined ENV for more details.