This is an old revision of the document!
conda
command available on your computer, and you can then use this conda
executable to select an existing distribution, or create new and independent Python distributions.activate
this environment in order to use itcdatm_py3
(assuming it exists)$ source /path_to_miniconda/etc/profile.d/conda.sh $ which conda /path_to_miniconda/condabin/conda $ conda env list [...] cdatm_py3 /path_to_miniconda/envs/cdatm_py3 some_other_env /path_to_miniconda/envs/some_other_env $ conda activate cdatm_py3 (cdatm_py3) $ which python /path_to_miniconda/envs/cdatm_py3/bin/python
base
. Note that the python
binary of the base
environment is not located in the same directory hierarchy of the other environments (i.e. there is no envs/
subdirectory$ conda activate base (base) $ which python /path_to_miniconda/bin/python
~/miniconda3
on Linux). Do not use the default installation location, if you want to avoid disk space related problems (disk full, quota exceeded, …)~/.conda
on Linux) for the installationdefault
channel (or repository) provided by the conda repository. This is not very useful (and could even cause complex dependency problems) because we will be mostly using (the same) packages provided by the conda-forge channel, in order to avoid complex package dependency problems.Note: some extra details are available on the much older page Installing and maintaining UV-CDAT with conda. You can check later the Useful conda commands, but the official conda documentation and the Cheat sheet are probably more up-to-date.
By Linux-like, we mean:
$ cd /home/scratch01/$USER
$ mkdir /homedata/$USER/Scratch $ cd /homedata/$USER/Scratch
C:\Scratch\<your_login>
directory:cd /mnt/c/Scratch/<your_login>
wget
to download the latest installer (138 Mb as of 22 Mar 2024):$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh $ ls -lh Miniconda3-latest-Linux-x86_64.sh [...] 138M Feb 27 20:40 Miniconda3-latest-Linux-x86_64.sh
We assume below that we are in the directory where we have downloaded the installer
/path_to_miniconda3/
/home/share/unix_files/cdat/miniconda3_2024-03
/homedata/$USER/miniconda3_2024-03
$ bash Miniconda3-latest-Linux-x86_64.sh
<SPACE>
several times…) and accept it/path_to_miniconda3/
$HOME/miniconda3
no
to the question Do you wish to update your shell profile to automatically initialize conda?
.no
, you can apparently:conda init –reverse $SHELL
conda config –set auto_activate_base false
miniconda3
directory size is 647 Mb (as of March 2024)$ du -sh miniconda3_2024-03 647M miniconda3_2024-03 $ du -sh miniconda3_2024-03/* 47M miniconda3_2024-03/bin 16K miniconda3_2024-03/cmake 8.0K miniconda3_2024-03/compiler_compat 32M miniconda3_2024-03/_conda 8.0K miniconda3_2024-03/condabin 976K miniconda3_2024-03/conda-meta 4.0K miniconda3_2024-03/envs 28K miniconda3_2024-03/etc 18M miniconda3_2024-03/include 317M miniconda3_2024-03/lib 92K miniconda3_2024-03/LICENSE.txt 1.1M miniconda3_2024-03/man 232M miniconda3_2024-03/pkgs 396K miniconda3_2024-03/sbin 1.5M miniconda3_2024-03/share 12K miniconda3_2024-03/shell 8.0K miniconda3_2024-03/ssl 8.0K miniconda3_2024-03/x86_64-conda_cos7-linux-gnu 8.0K miniconda3_2024-03/x86_64-conda-linux-gnu
source /path_to_miniconda3/etc/profile.d/conda.sh
source /homedata/jypmce/miniconda3_2024-03/etc/profile.d/conda.sh
source /path_to_miniconda3/etc/profile.d/conda.csh
source /home/share/unix_files/cdat/miniconda3_2024-03/etc/profile.d/conda.csh
conda
command, and use it to initialize the base environment$ which conda $ which python /usr/bin/python $ source /homedata/jypmce/miniconda3_2024-03/etc/profile.d/conda.sh $ which conda /homedata/jypmce/miniconda3_2024-03/condabin/conda $ which python /usr/bin/python $ conda activate base (base) $ which conda /homedata/jypmce/miniconda3_2024-03/bin/conda (base) $ which python /homedata/jypmce/miniconda3_2024-03/bin/python (base) $ conda deactivate $ which conda /homedata/jypmce/miniconda3_2024-03/condabin/conda $ which python /usr/bin/python
conda will probably work fine with the default settings if you create simple new environments with just one package and its dependencies. Besides, conda works much better and faster since the end of 2023, now that it is using the mamba solver instead of the default solver.
We are power users, and we intend to create complex environments combining lots of packages available in conda-forge
, with complex dependencies, and we may run into dependency problems when combining packages coming from both conda and conda-forge. The solution is to configure conda to always use conda-forge, and completely update Miniconda3 itself with packages coming from conda-forge
Most of the packages we will install will be provided by the conda-forge channel (-c conda-forge
option). The installation steps will also add dependencies that will theoretically come from conda-forge, but could also come from the defaults channel.
The following will make sure that we only get packages from conda-forge unless the requested packages really don't exist on conda-forge (see Managing channels and Using multiple channels => How to fix it)
$ conda config --add channels conda-forge $ conda config --set channel_priority strict $ cat ~/.condarc channels: - conda-forge - defaults channel_priority: strict
$ cat ~/.condarc cat: /home/jypmce/.condarc: No such file or directory $ conda config --get channels $ conda config --prepend channels conda-forge $ conda config --set channel_priority strict $ conda config --get channels --add channels 'defaults' # lowest priority --add channels 'conda-forge' # highest priority $ cat ~/.condarc channels: - conda-forge - defaults channel_priority: strict
conda info
conda config –show
$ conda update --all [...]
miniconda3
directory size goes from 432 Mb to 581 Mb. This directory will keep on growing, which is the reason why you should put it on a (preferably non backed up) disk where you have enough spaceconda
package (just in case we did not get it with the update)conda update -n base conda
rm Miniconda3-latest-Linux-x86_64.sh
When you open a terminal, your shell needs to know where to find the conda
command used to initialize an environment, or switch between environments
You were asked the following question when installing miniconda3: Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no]
conda
directly available when you open a new terminal~/.bashrc
source <installation_path>/miniconda3/etc/profile.d/conda.sh
~/.cshrc
source <installation_path>/miniconda3/etc/profile.d/conda.csh
We choose not to add a conda activate env_name
line to the shell configuration files, in order to avoid side effects. When we open a new terminal, we get the default python available on the system. When we need a specific python environment, we just open a new window and then explicitly type: conda activate env_name
In the case of python environments maintained by a single user, but used by several users, we could do the same as in the General case, but it can be useful to have the users source an intermediate initialization file, that will then source the initialization file used in the general case. This makes it easier to maintain and change the environments, without asking users to make changes.
~/.bashrc
something likesource ~main_installer_login/.conda3_jyp.sh
.conda3_jyp.sh
file looking like conda3_jyp.sh.txt~/.cshrc
something likesource ~main_installer_login/.conda3_jyp.csh
.conda3_jyp.csh
file looking like conda3_jyp.csh.txt
Even when using a proper .condarc
in order to get packages coming only from conda-forge, conda install
may fail to solve the dependencies after meditating during an enormous time (e.g. Solving environment: failed with initial frozen solve. Retrying with flexible solve.), when we try to deal with complex environments (i.e. we already have lots of installed packages and we want to add even more packages).
Using CDAT as a base environment, and adding a lot of extra packages is a complex environment.
The only solution seems to replace conda
with mamba, a reimplementation of the conda package manager in C++ (Making conda fast again):
mamba
in the base (i.e. miniconda) environmentconda install mamba -n base -c conda-forge
mamba
instead of conda
when installing packages.install -c conda forge
any more, because conda-forge
is now the default source of new packagesmamba install lots_of_packages
[ PMIP3 Wiki Home ] - [ Help! ] - [ Wiki syntax ]