According to Anaconda's Managing Environments webpage, you can create a yml
file and then create a new environment by using this yml
file. The advantage being that "this file handles both the environment's pip packages and conda packages."
So firstly you create the yml
file from the environment you want to clone (I'm using Windows PowerShell as an example of the expected output in the terminal):
(base) C:\Users\user> conda activate envIWantToClone
(envIWantToClone) C:\Users\user> conda env export > myEnv.yml
This yml
file will be in the directory of the terminal, i.e. C:\Users\user
. Then you have to edit the first line of the file, changing the name of the environment from envIWantToClone
to clonedEnv
, for example:
# name: envIWantToClone # CHANGE THIS TO clonedEnv
name: clonedEnv
channels:
- defaults
- cona-forge
dependencies:
...
Then back in the terminal (which environment is currently active does not matter at this point):
(envIWantToClone) C:\Users\user> conda env create -f environment.yml
Then check if everything is working correctly
(envIWantToClone) C:\Users\user> conda activate clonedEnv
(clonedEnv) C:\Users\user> |