Replacing an existing Conda installation
Due to changes in software and licensing, you may wish to replace your current
installation of conda with a different version such as Miniforge. There are three different ways to maintain your environments during this change: using the conda "clone" feature, build a new identical environment, or by modifying .condarc
.
This guide assumes you have installed a new conda version into a different directory than your existing installation, e.g. your current installation is in the directory ~/miniconda3
and you install Miniforge into ~/miniforge3
.
Warning
As you go through this guide, regularly use the command which conda
to make sure you are using the correct installation for each command.
Using conda --clone
First, check that you are using your new conda version by running
input | |
---|---|
1 |
|
in your terminal, logged on to an HPCC dev node.
Then, you can run the clone command:
input | |
---|---|
1 |
|
where myclone
is the name of your copy, and /path/to/myenv
is the full path to the environment you want to copy e.g. /mnt/home/MyMSUID/miniconda3/myenv
.
You can repeat this for all of your existing environments. Once you have completed the process, you can delete your previous conda version entirely.
Warning
Check that you have enough file space and file count available to make full copies of your old environments using the quota
command.
Using conda list
To build an identical environment with the same packages as the original, activate your original conda version. Check that you are using your original conda version by running
input | |
---|---|
1 |
|
in your terminal, logged on to an HPCC dev node.
Then activate the environment you want to export. Then run
input | |
---|---|
1 |
|
where spec-file.yml
is a file containing the precise packages used to build your environment.
Deactivate your original conda version.
Then, activate your new conda version and run the command
input | |
---|---|
1 |
|
which will create a new environment named myenv
with the same package list. You can repeat this for all of your existing environments. Once you have completed the process, you can delete your previous conda version entirely.
Note
If you are low on space, you can create the specification files, then delete the old conda installation before creating the new environments. Make sure you try out the specification file process to ensure it works for your new conda version.
Modifying .condarc
Note
This also works for conda environments in research spaces!
To avoid duplicating environments or downloading packages, you can point your new conda version at your old environments by using the .condarc
settings file.
First, check that you are using your new conda version by running
input | |
---|---|
1 |
|
in your terminal, logged on to an HPCC dev node.
Then, run the command
input | |
---|---|
1 |
|
where /path/to/old/envs
is the path to your original environments e.g. /mnt/home/MyMSUID/miniconda3/envs
. You can find this path by running conda env list
using your old conda version, which will produce output like this:
output | |
---|---|
1 2 3 4 |
|
You can check that the path in .condarc
is correct by running more .condarc
in your home directory. The output should look like:
output | |
---|---|
1 2 |
|
and then run conda env list
using your new conda version, which should produce output like this:
output | |
---|---|
1 2 3 4 |
|
Note how base
is in the new conda version, while myenv
is the old path. You can then activate the old environment using the new version with conda activate myenv
as usual.