User Tools

Site Tools


other:uvcdat:cdat_conda:miniconda3_install

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
other:uvcdat:cdat_conda:miniconda3_install [2021/03/08 15:26]
jypeter [Multi-user installation]
other:uvcdat:cdat_conda:miniconda3_install [2024/04/16 15:41]
jypeter [Web sites] Added repositories
Line 1: Line 1:
 ====== JYP steps for installing Miniconda3 ====== ====== JYP steps for installing Miniconda3 ======
  
-===== What? Why? =====+===== Why should you use Miniconda3 ​? =====
  
-  * //​Miniconda3//​ is a minimal ​python environment/​distribution that can be used for creating more complete working environments. It will basically make ''​conda''​ available on your computer, and then you can use ''​conda''​ to install ​and update more //stuff//.+  ​* **//​Miniconda3//​ is a minimal/bootstrap Python ​distribution** that can be used for creating more complex Python distributions.\\ It will basically make a recent ​''​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.
  
-  * A python ​//​environment//​ is basically where and how you install ​python. A python //​distribution//​ is more which packages you have chosen to install together in the environment. ​Hmmm, well, these are very similar things!+  * A **conda ​//​environment//​** is basically ​(the short name of the directory) ​where you install ​the Python that you will use (independently of //​Miniconda3//​ itself)You have to ''​activate''​ this environment in order to use it\\ **python //​distribution//​** is the collection of packages ​(and their dependencies) ​you have chosen to install together in a given environment. 
 +    * Example: initializing an environment named ''​cdatm_py3''​ (assuming it exists)<​code>​$ source /​path_to_miniconda/​etc/​profile.d/​conda.sh
  
-  * You don't need to be (and **you should not be**) //root// when you install Miniconda3. You just need enough disk space where you have write access+$ which conda 
 +/path_to_miniconda/condabin/conda
  
-  * If you are installing Miniconda3 in a Linux environment on a [[other:​win10wsl|Windows 10 computer using Windows Subsystem for Linux (WSL)]], pay special attention to the instructions on the **WSL** lines+$ conda env list 
 +[...] 
 +cdatm_py3 ​               /​path_to_miniconda/​envs/​cdatm_py3 
 +some_other_env ​          /​path_to_miniconda/​envs/​some_other_env
  
-  * The way you do things will depend on how you are going to use python? Are you installing the environment just for you, or for multiple users?+$ conda activate cdatm_py3
  
-  ​We could also start with the //Anaconda// installer ​that will install a much more complete ​python environment, ready for use, but we choose ​not to do that because Anaconda requires more disk space at the beginning, with all its components coming from the ''​default''​ //channel// (or //repository//) provided by the [[https://docs.conda.io/projects/conda/en/latest/glossary.html#​conda-repository|conda repository]]. It'not useful because we will be mostly using (the samepackages provided by the [[https://conda-forge.org/feedstock-outputs/|conda-forge]] channel.+(cdatm_py3) $ which python 
 +/​path_to_miniconda/​envs/​cdatm_py3/​bin/​python 
 +</​code>​ 
 +    ​The //special// environment where //​Miniconda3//​ itself is installed is called ''​base''​. Note that the ''​python''​ binary of the //special// ''​base'' ​environment ​is not located in the same directory hierarchy as the ''​python'' ​of the other environments (i.e. there is no ''​envs/''​ subdirectory<​code>​$ conda activate base 
 + 
 +(base) $ which python 
 +/path_to_miniconda/bin/python 
 +</​code>​ 
 + 
 +  * You **don'​t need to be (and you should not be) //root//** when you install //​Miniconda3//. You just **need ​//enough// disk space** on a disk where you have write access 
 +    * **WARNING**:​ by default, ​//​Miniconda3//​ will install itself and subsequent Python environments in a sub-directory of your home directory (''​~/​miniconda3''​ on Linux). **Do not use the default installation location**, if you want to avoid disk space related problems (//disk full//, //quota exceeded//, ...) 
 +      * **WARNING**older versions of //Miniconda3// used a **hidden sub-directory** of your home directory (''​~/​.conda''​ on Linux) for the installation 
 +    * Choose carefully where you will install //​Miniconda3//,​ because the size of the installation directory will start at a few Gb and will keep on growing
  
-The steps on this page are adapted from the much older (but with lots of extra and possibly useful details) [[other:uvcdat:conda_notes#​installing_miniconda|installing miniconda]] instructions+  * You //could// also start with the full //​Anaconda// ​(instead ​of //​Miniconda//​installer that will install a much more complete python environment,​ ready for use.\\ **We choose not to use the full //​Anaconda//​ installer** because: 
 +    * it requires more disk space than //​Miniconda3//​ during the initial installation,​ 
 +    * all the //​Anaconda//​ installer packages come from the ''​default''​ //channel// (or //​repository//​) provided by the [[https://​anaconda.org/​|conda repository]].\\ This is not very useful for us (and could even cause complex dependency problems later) because we will be mostly using (the same) packages provided by the [[https://​conda-forge.org/​feedstock-outputs/​|conda-forge]] //​channel//,​ **in order to avoid complex package dependency problems**.
  
 ===== Installing miniconda3 on a Linux-like computer ===== ===== Installing miniconda3 on a Linux-like computer =====
  
 <WRAP center round tip 60%> <WRAP center round tip 60%>
-By //​Linux-like//,​ we mean: +By **//​Linux-like//​**, we mean: 
-  * A native Linux computer+  * A native Linux computer ​(or server)
   * A windows 10 computer with [[other:​win10wsl|WSL+Ubuntu installed]]   * A windows 10 computer with [[other:​win10wsl|WSL+Ubuntu installed]]
-  * A mac where you can use Linux in a terminal+  * A Mac where you can use Linux in a terminal
 </​WRAP>​ </​WRAP>​
  
 +<WRAP center round info 60%>
 +**//Pure Windows//** Note: you can also follow the steps listed in the [[https://​docs.anaconda.com/​free/​miniconda/#​quick-command-line-install|Windows section of "Quick command line install"​]] to install a //pure Windows// version of miniconda3, and then follow the steps listed in the next sections of this page.\\ We assume below that the installer is downloaded in the ''​C:​\Scratch\your_login''​ directory, and we install Miniconda3 in a ''​C:​\Utils\miniconda3_2024-03''​ directory. <​code>​PS C: cd C:​\Scratch\your_login
 +PS C:​\Scratch\your_login>​ curl https://​repo.anaconda.com/​miniconda/​Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe
 +PS C:​\Scratch\your_login>​ .\miniconda.exe
 +PS C:​\Scratch\your_login>​ del .\miniconda.exe
 +</​code>​
 +</​WRAP>​
  
-  * Get the [[https://​repo.anaconda.com/​miniconda/​Miniconda3-latest-Linux-x86_64.sh|Python 3.8 Linux 64-bit (bash installer)]] (unless there is a [[https://​conda.io/​miniconda.html|more recent version?]]) 
-    * Find some temporary space on Linux (or Windows, if you are using [[other:​win10wsl|WSL]]) 
-      * e.g. Linux at LSCE:\\ ''​cd /​home/​scratch01/<​your_login>''​ 
-      * e.g. WSL, assuming that there is a ''​C:​\Scratch\<​your_login>''​ directory:​\\ ''​cd /​mnt/​c/​Scratch/<​your_login>''​ 
-    * Use ''​wget''​ to download the installer:​\\ ''​wget https://​repo.anaconda.com/​miniconda/​Miniconda3-latest-Linux-x86_64.sh''​ (90 Mb, 26 Feb 2021) 
  
-  * Execute the installer 
-    * ''​bash Miniconda3-latest-Linux-x86_64.sh''​ 
-      * Accept the license 
-      * Note: at the end of the installation (next step), **answer //no// to the following question**, so that the installer does **not** change your existing shell initialization files!\\ ''​Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no]''​ => **NO** 
-      * Specify an explicit installation path **outside of your //home// directory**,​ with enough disk space (more than 3 Gb if you are going to install CDAT and some extra packages), preferably on a disk that is not backed up: 
-        * Installations by //JYP//: 
-          * Linux at LSCE: ''/​home/​share/​unix_files/​cdat/​miniconda3'',​ or a ''​miniconda3<​some_version>''​ subdirectory of ''/​home/​share/​unix_files/​cdat/'' ​ 
-          * Linux on ciclad: ''/​data/​jypmce/​cdat/​miniconda3'',​ or a ''​miniconda3<​some_version>''​ sub-directory of ''/​data/​jypmce/​cdat/''​ 
-        * WSL: installing to a directory that is not in ''/​home/''​ <wrap hi>does not work</​wrap>​ (e.g. ''/​mnt/​h/​CDAT/​miniconda3'',​assuming there is a ''​H:​\CDAT\''​ directory, does not work)\\ You need to accept the installation in the default location: ''/​home/<​your_login>/​miniconda3''​ 
-      * The resulting ''​miniconda3''​ directory size is 342M\\ <​code>​ > du -sh miniconda3 
-342M    miniconda3 
  
- > cd miniconda3+==== Downloading the Miniconda3 installer ====
  
- > du -sh * +  ​We use a download link that always point to the [[https://​docs.anaconda.com/​free/​miniconda/#​latest-miniconda-installer-links|latest version of the Linux installer]] 
-20M     bin +    ​* For the Linux computers we commonly use, we need the //​Miniconda3 Linux 64-bit// link: https://​repo.anaconda.com/​miniconda/​Miniconda3-latest-Linux-x86_64.sh 
-0       ​compiler_compat +      * Note: Mac users should use the latest [[https://​docs.anaconda.com/​free/​miniconda/#​latest-miniconda-installer-links|macOS installer]] appropriate for their computer 
-4.0K    condabin +    * The installer is based on **Python 3.12 as of March 2024**
-684K    conda-meta +
-0       ​envs +
-16K     etc +
-5.5M    include +
-4.0K    info +
-198M    lib +
-12K     ​LICENSE.txt +
-114M    pkgs +
-604K    share +
-4.0K    shell +
-0       ssl +
-0       ​x86_64-conda_cos6-linux-gnu</​code>​+
  
-  * Initialize the newly installed conda environment (this will initialize the environment only in the current terminal):​ +  ​* Find some temporary space on Linux (or Windows, if you are using [[other:​win10wsl|WSL]]) 
-    * bash shell: ''​source ​<​installation_path>​/miniconda3/​etc/​profile.d/​conda.sh''​ +    * e.g. Linux at **LSCE**:\\ ''​$ cd /​home/​scratch01/​$USER''​ 
-    * tcsh shell: ''​source ​<​installation_path>​/miniconda3/​etc/​profile.d/​conda.csh''​+    * e.g. Linux at **spiritx**:<​code>​$ mkdir /​homedata/​$USER/​Scratch 
 +$ cd /​homedata/​$USER/​Scratch</​code>​ 
 +    * e.g. Linux on a **personal PC/Mac desktop/​laptop**:​ use a scratch/​temporary directory with //enough// space 
 + 
 +  * Use ''​wget''​ to download the latest installer (138 Mb as of 22 Mar 2024):\\ <​code>​$ 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</​code>​ 
 + 
 +==== Using the Miniconda3 installer ==== 
 + 
 +We assume below that we are in the [[#​downloading_the_installer|directory where we have downloaded the installer]] 
 + 
 +  * **Determine the directory where you will install miniconda3 and all the Python environments** based on this version of miniconda3, but **do not create the directory** (the installation script will do it)\\ **We will later refer to this location as ''/​path_to_miniconda3/''​** 
 +    * Remember that **you will need a few Gb of available space** 
 +    * **If you want to share this installation with other users**, the directory has to be readable by these users 
 +    * At LSCE, **do not** install in a sub-directory of your home directory! 
 +      * On other servers and computers, you should also **avoid installing in your //home// directory**,​ if you want to be able to easily make backups or your //home//, without backing up thousands of files related to your Python installation... 
 +    * We add some date or version information at the end of the directory, in order to differentiate it from other (older of future) installations 
 +    * e.g. Linux at **LSCE**: ''/​home/​share/​unix_files/​cdat/​miniconda3_2024-03''​ 
 +    * e.g. Linux at **spiritx**:​ ''/​homedata/​$USER/​miniconda3_2024-03''​ 
 +    * Linux (including WSL) on a **personal PC/Mac desktop/​laptop**:​ find a directory with enough space (including space for adding more packages and their future updates) 
 +      * You may want to use a directory that you are not backing up, if you want to avoid having to save thousands of files... 
 + 
 +  * Execute the installer with ''​$ bash Miniconda3-latest-Linux-x86_64.sh''​ 
 +    * Review the license (type ''<​SPACE>''​ several times...) and accept it 
 +    * When asked for the installation directory, specify the directory location chosen in the previous step, and **not the default directory** 
 +      * e.g. specify\\ ''/​path_to_miniconda3/''​\\ instead of the default\\ ''​$HOME/​miniconda3''​ 
 +    * **Answer ''​no''​ to the question ''​Do you wish to update your shell profile to automatically initialize conda?''​**.\\ Otherwise the installation will make changes to your shell configuration files 
 +      * If you forget to answer ''​no'',​ you can apparently:​ 
 +        * remove the changes to your shell configuration files by typing later: ''​conda init --reverse $SHELL''​ 
 +        * or at least disable the automatic activation of the environment (that might have side effect) by typing: ''​conda config --set auto_activate_base false''​ 
 +      * The resulting ''​miniconda3''​ directory size is 647 Mb (as of March 2024)\\ <​code>​$ 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 
 +</​code>​ 
 + 
 +  ​* Initialize the newly installed conda environment (this will initialize the environment ​**only in the current terminal**): 
 +    ​* **bash shell**: ''​source /path_to_miniconda3/​etc/​profile.d/​conda.sh''​ 
 +      * e.g. (spiritx): ''​source /​homedata/​jypmce/​miniconda3_2024-03/​etc/​profile.d/​conda.sh''​ 
 +    ​* **tcsh shell**: ''​source /path_to_miniconda3/​etc/​profile.d/​conda.csh''​ 
 +      * e.g. (LSCE): ''​source /​home/​share/​unix_files/​cdat/​miniconda3_2024-03/​etc/​profile.d/​conda.csh''​
  
   * Check if you can use the ''​conda''​ command, and use it to initialize the //base// environment   * Check if you can use the ''​conda''​ command, and use it to initialize the //base// environment
-    * <​code>​$ which conda +    * e.g. on **spiritx1**: ​<​code>​$ which conda
-<​installation_path>/​miniconda3/​condabin/​conda+
 $ which python $ which python
 /​usr/​bin/​python /​usr/​bin/​python
-$ conda activate+ 
 +$ 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 (base) $ which python
-<​installation_path>​/miniconda3/bin/python</​code>​ +/homedata/jypmce/miniconda3_2024-03/bin/python
-  * Update the new installation +
-    * <​code>​$ conda update ​--all +
-[...]</code> +
-    * During the update, the ''​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// space+
  
-  * Make sure we have the latest ''​conda''​ package ​(just in case we did not get it with the //update//)\\ ''​conda update -n base conda''​+(baseconda deactivate
  
-  * Remove the installer later, when you have tester your installation:​\\ ''​rm Miniconda3-latest-Linux-x86_64.sh''​+$ which conda 
 +/​homedata/​jypmce/​miniconda3_2024-03/​condabin/​conda 
 +$ which python 
 +/​usr/​bin/​python 
 +</​code>​
  
-===== Initializing ​conda in new terminals =====+  * Remove the //​Miniconda3//​ installer: ''​$ rm Miniconda3-latest-Linux-x86_64.sh''​ 
 +==== Fine-tuning ​conda to use (only) conda-forge ​====
  
-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+  * ''​conda'' ​will probably work fine with the default settings **if you create simple new environments** with just one package and its dependencies.
  
-==== General case ====+  * ''​conda''​ works much better and faster since the end of 2023 (''​conda''​ versions starting at ''​23.10''​),​ now that it is [[https://​conda.org/​blog/​2023-07-05-conda-libmamba-solver-rollout/​|using the mamba solver]] instead of the default solver. 
 +    * If you have followed all the steps of this section in order to **use only //​conda-forge//​ packages**, and there are still some problems with a recent version of ''​conda'',​ try to install and use [[https://​mamba.readthedocs.io/​|mamba]],​ as a drop-in replacement of conda 
 +    * Historical note: before ''​conda''​ used ''​libmamba'',​ we had to use ''​mamba''​ (instead of ''​conda''​) for dealing with our complex Python environments:​ 
 +      * [[https://​wolfv.medium.com/​making-conda-fast-again-4da4debfb3b7|Making conda fast again]] 
 +      * [[https://​github.com/​conda/​conda/​issues/​9367#​issuecomment-793968239|Solving environment:​ failed with initial frozen solve. Retrying with flexible solve.]]
  
-You were asked the following question ​when installing miniconda3: ​//Do you wish the installer to initialize ​Miniconda3 ​by running conda init? [yes|no]//+  * We are power users, and **we intend to create complex Python environments** combining lots (and lots) of packages available from ''​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 only from conda-forge
  
-  * If you answered //​yes//, ​the installer probably added some very complicated lines to your shell configuration files, but you probably have ''​conda''​ directly available when you open a new terminal +=== Changing ​the .condarc ​file ===
-  * if you answered //no// (as suggested), use a text editor to add an extra line to the appropriate configuration ​file +
-    * //bash// user: add this line to ''​~/​.bashrc''​\\ ''​source <​installation_path>/​miniconda3/​etc/​profile.d/​conda.sh''​ +
-    * //tcsh// user: add this line to ''​~/​.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 systemWhen we need a specific python environment,​ we just open a new window and then explicitly type''​conda activate env_name''​+The following steps will **make sure that we only get packages from //​conda-forge//​**  (same thing as using the ''​-c conda-forge'' ​option) by default unless ​the requested packages really don't exist on //​conda-forge//​More details in [[https://docs.conda.io/​projects/​conda/​en/​latest/​user-guide/​tasks/​manage-channels.html|Managing channels]]
  
-==== Multi-user installation ====+<​code>​$ cat ~/​.condarc 
 +cat: /​home/​jypmce/​.condarc:​ No such file or directory
  
-In the case of **python environments maintained by a single user, but used by several users**, we could do the same as above, 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.+$ conda config --get channels
  
-  * //bash// users: ask them to add something like to ''​~/​.bashrc''​\\ ''​source ​ ~main_installer_login/​.conda3_jyp.sh''​\\ \\ with a ''​.conda3_jyp.sh''​ file looking like {{ :​other:​uvcdat:​cdat_conda:​conda3_jyp.sh.txt |}}+$ conda config --prepend channels conda-forge
  
-  * //tcsh// users: ask them to add something like to ''​~/​.cshrc''​\\ ''​source ​ ~main_installer_login/​.conda3_jyp.csh''​\\ \\ with a ''​.conda3_jyp.csh''​ file looking like {{ :​other:​uvcdat:​cdat_conda:​conda3_jyp.csh.txt |}} +$ conda config --set channel_priority strict
-==== bash shell users ====+
  
-See the ''​~your_login/​.conda3_jyp.sh''​ file below, and how to use it, **in a bash shell**. In a **tcsh shell**, see the ''​~jypeter/​.conda3_jyp.csh''​ further down. In both shell cases, if you are installing your own version of python, you need to use your own location of the initialization files in the ''​source''​ lines, and you can use another file name than ''​conda3_jyp''​+$ conda config --get channels 
 +--add channels ​'defaults' ​  # lowest priority 
 +--add channels ​'conda-forge' ​  # highest priority
  
-<​code>​which python +cat ~/.condarc 
-/usr/​bin/​python+channels: 
 +  - conda-forge 
 +  - defaults 
 +channel_priority:​ strict 
 +</code>
  
-$ cat ~jypeter/​.conda3_jyp.sh+=== Getting conda configuration information ===
  
-# Conda initialization by JYP, NEW style +  ​* [[https://docs.conda.io/projects/conda/en/latest/commands/config.html|conda config]] documentation 
-+  * Basic information''​conda info''​ 
-# Use this for working with conda and CDAT centrally managed by JYP +  * Full configuration''​conda config %%--%%show''​
-+
-# Execute this file in a BASH shell with +
-#     ​source path/​this_file +
-# Then get the list of available python distributions with +
-#     conda env list +
-# Then activate a specific distribution with +
-#     conda activate version_name +
-+
-# More details in: +
-  https://wiki.lsce.ipsl.fr/pmip3/doku.php/​other:​python:​starting#​conda-based_versions_of_uv-cdat +
-#   ​https:​//wiki.lsce.ipsl.fr/pmip3/doku.php/other:uvcdat:conda_notes +
-+
-# Jean-Yves Peterschmitt ​LSCE - 11/2018+
  
-source /​home/​share/​unix_files/​cdat/​miniconda3/​etc/​profile.d/​conda.sh+==== Updating (Mini)conda ====
  
-Use the alias below to easily determine where your python +We have to **completely update //​Miniconda3//​ at least once after installing //​Miniconda3//​** and [[#fine-tuning_conda_to_use_only_conda-forge|making conda-forge ​the highest priority channel]]
-# interpreter is located +
-alias wp="​which python"​+
  
-# Where are ALL the python interpreters ​in the search path +  * Check the current version of ''​conda''​ 
-alias wpa="​which ​-a python"​+    * <​code>​$ conda list -n base | grep conda 
 +# packages ​in environment at /​path_to_miniconda:​ 
 +conda                     ​24.1.2 ​         py312h06a4308_0 
 +conda-libmamba-solver ​    ​23.12.0 ​           pyhd3eb1b0_1 
 +[... and other packages with '​conda'​ in their name] 
 +</​code>​
  
-# The end+  * Completely update the //​Miniconda3//​ installation 
 +    * <​code>​$ conda update -n base --all 
 +Channels: 
 + - conda-forge 
 + - defaults 
 +Platform: linux-64 
 +Collecting package metadata (repodata.json):​ done 
 +Solving environment:​ done
  
-$ source ~jypeter/​.conda3_jyp.sh+## Package Plan ##
  
-$ conda activate +  environment location: ​/homedata/jypmce/miniconda3_2024-03
-(base) $ which python +
-/home/share/unix_files/​cdat/​miniconda3/​bin/​python+
  
 +
 +The following packages will be downloaded:
 +
 +    package ​                   |            build
 +    ---------------------------|-----------------
 +    conda-24.3.0 ​              ​| ​ py312h7900ff3_0 ​        1.1 MB  conda-forge
 +    conda-libmamba-solver-24.1.0| ​    ​pyhd8ed1ab_0 ​         40 KB  conda-forge
 +    python-3.12.2 ​             |hab00c5b_0_cpython ​       30.8 MB  conda-forge
 +[...]
 +The following NEW packages will be INSTALLED:
 +[...]
 +The following packages will be UPDATED:
 +[...]
 +  conda              pkgs/​main::​conda-24.1.2-py312h06a4308~ --> conda-forge::​conda-24.3.0-py312h7900ff3_0
 +[...]
 +The following packages will be SUPERSEDED by a higher-priority channel:
 +[...]
 +Proceed ([y]/n)? y
 +[...]
 +Preparing transaction:​ done
 +Verifying transaction:​ done
 +Executing transaction:​ done
 </​code>​ </​code>​
 +  * Check the updated version of ''​conda''​. Note that **(almost) all** the packages should now specify that they are provided by ''​conda-forge''​
 +    * <​code>​$ conda list -n base
 +conda                     ​24.3.0 ​         py312h7900ff3_0 ​   conda-forge
 +conda-libmamba-solver ​    ​24.1.0 ​            ​pyhd8ed1ab_0 ​   conda-forge
 +python ​                   3.12.2 ​         hab00c5b_0_cpython ​   conda-forge
 +</​code>​
 +    * You can use the following to determine if some packages are not provided by ''​conda-forge''​
 +      * <​code>​$ conda list -n base | grep -v conda-forge
 +# Name                    Version ​                  ​Build ​ Channel
 +libedit ​                  ​3.1.20230828 ​        ​h5eee18b_0
 +libffi ​                   3.4.4                h6a678d5_0
 +xz                        5.4.5                h5eee18b_0
 +</​code>​
 +      * It should not be a major problem if a few packages are not provided by ''​conda-forge''​.\\ It only means that some packages provided by the ''​anaconda''​ //channel// were more recent than the same packages provided by the ''​conda-forge''​ //channel// when the packages were updated
 +        * ''​libedit''​ example: [[https://​anaconda.org/​conda-forge/​libedit|version 3.1.20191231 @ conda-forge]] and [[https://​anaconda.org/​anaconda/​libedit|version 3.1.20230828 @ anaconda]]
  
-==== tcsh shell users ====+  * You can later update again the full //​Miniconda3//,​ or just the ''​conda''​ command.\\ This should not make any changes to the Python environment(s) have have installed with ''​conda''​ 
 +    * <​code>​$ conda update -n base --all 
 +[...] 
 +# All requested packages already installed.
  
-<​code>​ >which python +(base) $ conda update -n base conda 
-/​usr/​bin/​python+[...] 
 +# All requested packages already installed. 
 +</code> 
 + 
 +  * Note: during this installation,​ the ''​miniconda3''​ directory size grew from 763 Mb to 1.6 Gb, and we have not installed any custom Python environment yet! This is the reason why you should install //​Miniconda3//​ on a (preferably non backed up) disk where you have //enough// space 
 +    * <code>$ du -sh /​homedata/​jypmce/​miniconda3_2024-03 
 +736M    /​homedata/​jypmce/​miniconda3_2024-03 
 +[... update] 
 +$ du -sh /​homedata/​jypmce/​miniconda3_2024-03 
 +1.6G    /​homedata/​jypmce/​miniconda3_2024-03 
 +</​code>​ 
 + 
 +  * You can [[https://​docs.conda.io/​projects/​conda/​en/​latest/​commands/​clean.html|clean]] the initial //​Miniconda3//​ installation to free up some disk space. The documentation specifies //WARNING: This will break environments with packages installed using symlinks back to the package cache.// and **you should probably avoid using ''​clean''​ once you have installed new Python environments** (unless you are desperate for disk space and know how to do a complete re-installation if something breaks...) 
 +    * <​code>​(base) $ conda clean --all 
 +Will remove 154 (180.9 MB) tarball(s). 
 +Proceed ([y]/n)? y 
 + 
 +Will remove 1 index cache(s). 
 +Proceed ([y]/n)? y 
 + 
 +Will remove 74 (378.0 MB) package(s). 
 +Proceed ([y]/n)? y 
 + 
 +There are no tempfile(s) to remove. 
 +There are no logfile(s) to remove. 
 + 
 +(base) $ du -sh /​homedata/​jypmce/​miniconda3_2024-03 
 +457M    /​homedata/​jypmce/​miniconda3_2024-03 
 +</​code>​ 
 +===== Initializing conda in terminals ===== 
 + 
 +When you open a terminal, your shell needs to know where to find the ''​conda''​ command used to initialize an environment,​ or switch between existing environments. This can be **configured in the //shell// configuration files** 
 + 
 +==== Single-user installation ==== 
 + 
 +You were asked the following question when installing //​Miniconda3//:​ //Do you wish to update your shell profile to automatically initialize conda? [yes|no]//​ 
 + 
 +  * **If you answered //yes//**, the installer probably added some very complicated lines to your shell configuration files, and ''​conda''​ and the newly installer ''​python''​ are probably directly available when you open a new terminal. 
 + 
 +  * **If you answered //no//** ([[#​using_the_miniconda3_installer|as suggested]]),​ use a [[other:​newppl:​starting#​text_editors|text editor]] to add extra lines to the appropriate shell configuration file 
 +    * **bash shell** user : add these lines to ''​~/​.bashrc''​\\ <​code>​source /​path_to_miniconda3/​etc/​profile.d/​conda.sh 
 +alias pynit='​conda activate base'</​code>​ 
 +      * e.g. (spiritx):<​code>​source /​homedata/​jypmce/​miniconda3_2024-03/​etc/​profile.d/​conda.sh 
 +alias pynit='​conda activate base'</​code>​ 
 +    * **tcsh shell** user: add these lines to ''​~/​.cshrc''​\\ <​code>​source /​path_to_miniconda3/​etc/​profile.d/​conda.csh''​ 
 +alias pynit 'conda activate base'</​code>​ 
 +      * e.g. (LSCE):<​code>​source /​home/​share/​unix_files/​cdat/​miniconda3_2024-03/​etc/​profile.d/​conda.csh 
 +alias pynit 'conda activate base'</​code>​ 
 +    * When you have a custom Python environment installed (e.g. ''​my_power_env'',​ you can update the ''​pynit''​ alias to initialize this environment instead of the ''​base''​ environment (e.g. ''​conda activate my_power_env''​) 
 +    * You can also define other aliases, or use another name than ''​pynit''​! 
 + 
 +We choose **not** to directly add a ''​conda activate env_name''​ line to the shell configuration files. This would permanently initialize ''​env_name''​ and may cause future (and obscure) side effects. 
 + 
 +When we open a new terminal, we get the default Python available on the system. If we need a specific Python environment,​ we just open a new window and then explicitly type ''​conda activate env_name''​ or the ''​pynit''​ alias defined above 
 + 
 +==== Multi-user installation ==== 
 + 
 +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. 
 + 
 +  * ask //bash// users to add to ''​~/​.bashrc''​ something like\\ ''​source ​ ~main_installer_login/​.conda3_jyp.sh''​\\ \\ with a ''​.conda3_jyp.sh''​ file looking like {{ :​other:​uvcdat:​cdat_conda:​conda3_jyp.sh.txt |}} 
 + 
 +  * ask //tcsh// users to add to ''​~/​.cshrc''​ something like\\ ''​source ​ ~main_installer_login/​.conda3_jyp.csh''​\\ \\ with a ''​.conda3_jyp.csh''​ file looking like {{ :​other:​uvcdat:​cdat_conda:​conda3_jyp.csh.txt |}} 
 + 
 +===== Keeping Miniconda3 up-to-date ===== 
 + 
 +  * Just type ''​conda update -n base %%--%%all''​ as shown in the [[#​updating_mini_conda|Updating (Mini)conda]] section 
 + 
 +  * The ''​base''​ (miniconda3) and the other environments are all independent and can be updated independently 
 + 
 +  * It is up to you to decide if you want to update environments or not 
 +===== conda resources ===== 
 + 
 + 
 + 
 + 
 +==== Web sites ==== 
 + 
 +  * [[https://​docs.conda.io/​projects/​conda/​en/​stable/​|Official conda website]] 
 +    * [[https://​docs.conda.io/​projects/​conda/​en/​stable/​user-guide/​cheatsheet.html|Cheat sheet]] (2 pages, for people in a hurry) 
 +    * [[https://​docs.conda.io/​projects/​conda/​en/​stable/​commands/​|Commands'​ reference]] 
 +  * Package repositories 
 +    * [[https://​conda-forge.org/​packages/​|conda-forge]] <= recommended source of packages 
 +    * [[https://​anaconda.org/​|default]] 
 + 
 + 
 +==== Useful commands ==== 
 + 
 +  * Get help 
 +    * ''​conda -h''​ 
 +      * ''​conda //command// %%--%%help'':​ help for a specific //​command//​ 
 +  * Available environments 
 +    * ''​conda env list''​ 
 +  * Activate an existing environment (available in ''​conda env list''​) or go back to the default Python 
 +    * ''​conda activate existing_environment''​ 
 +      * ''​conda activate''​ (without specifying an environment name) will activate the ''​base''​ environment 
 +    * Go back to the default Python available on the system 
 +      * ''​conda deactivate''​ 
 +    * You can type ''​which python''​ to determine where is the current Python you are using 
 +      * <​code>​(base) $ which python 
 +/​homedata/​jypmce/​miniconda3_2024-03/​bin/​python 
 + 
 +(base) $ conda deactivate 
 + 
 +which python 
 +/​usr/​bin/​python</​code>​ 
 +    * Note: //before conda ''​4.6''//,​ you had to type ''​**source** activate existing_environment''​ and ''​**source** deactivate''​ 
 +  * Get the list of installed packages, their version, and where they come from (e.g. ''​conda-forge'',​ ''​pip''​) 
 +    * ''​conda list [-n existing_environment]''​ 
 +  * Create an environment 
 +    * ''​conda create -n new_environment_name package1 package2 packageN''​ 
 +  * Delete all packages from an environment **and the environment** itself 
 +    * ''​conda remove -n crap_environment %%--%%all''​ 
 +  * Look for a package 
 +    * ''​conda search package_exact_name''​\\ ''​conda search '​*package_partial_name*'''​ 
 +      * Note: ''​search''​ with wildcards seems to fail in a tcsh shell, as of April 2024 ([[https://​github.com/​conda/​conda/​issues/​9771|CSH install/​search fail with '​*'​ variable in an argument]]) 
 +  * Installing and removing packages\\ Add ''​-n target_environment''​ to act on another environment than the active one 
 +    * ''​conda install package1 package2 packageN''​ 
 +      * Add ''​%%--%%channel channel_url_or_alias''​ to install from a specific //​channel//​ 
 +        * If there is no URL, conda will use the value of ''​channel_alias''​ that defaults to https://​conda.anaconda.org/​ 
 +        * UV-CDAT relies on packages maintained in [[https://​conda-forge.github.io|conda-forge]] ([[http://​wesmckinney.com/​blog/​conda-forge-centos-moment/​|why conda-forge?​]]) and the installation commands should include the following channel option:\\ ''​%%--%%channel conda-forge''​ 
 +    * ''​conda remove package1 package2 packageN''​ 
 +  * Updating conda (update the //conda// package, not the full Miniconda) 
 +    * ''​conda update -n base -c defaults conda''​ 
 +  * Downgrading conda (required for installing UV-CDAT 2.10) 
 +    * <​code>​bash-4.1$ conda install -n root "​conda<​4.3.13"​ 
 +Fetching package metadata ......... 
 +Solving package specifications:​ . 
 + 
 +Package plan for installation in environment /​home/​share/​unix_files/​cdat/​miniconda2:​ 
 + 
 +The following packages will be DOWNGRADED due to dependency conflicts:
  
- >​cat ~jypeter/​.conda3_jyp.csh +    conda: ​4.3.13-py27_0 ​--> 4.3.11-py27_0
-# Conda initialization by JYP, NEW style +
-+
-# Use this for working with conda and CDAT centrally managed by JYP +
-+
-# Execute this file in a TCSH shell with +
-#     ​source path/​this_file +
-# Then get the list of available python distributions with +
-    conda env list +
-# Then activate a specific distribution with +
-#     conda activate version_name +
-+
-# More details in: +
-#   https://wiki.lsce.ipsl.fr/​pmip3/​doku.php/​other:​python:​starting#​conda-based_versions_of_uv-cdat +
-#   ​https://​wiki.lsce.ipsl.fr/​pmip3/​doku.php/​other:​uvcdat:​conda_notes +
-+
-# Jean-Yves Peterschmitt - LSCE - 11/2018+
  
-source ​/home/​share/​unix_files/​cdat/​miniconda3/​etc/​profile.d/​conda.csh+Proceed ([y]/n)? y
  
-Use the alias below to easily determine where your python +conda-4.3.11-p 100% |###############################################################​| Time: 0:​00:​00 ​  4.28 MB/s
-interpreter is located +
-alias wp "which python"​+
  
-# The end+bash-4.1$ conda info 
 +Current conda install:
  
- >​source ​ ~jypeter/.conda3_jyp.csh+               ​platform : linux-64 
 +          conda version : 4.3.11 
 +       conda is private : False 
 +      conda-env version : 4.3.11</​code>​
  
- >conda activate+  * conda does not automatically clean the content of the ''​pkgs''​ directory! Use the following to //Remove index cache, lock files, tarballs, unused cache packages, and source cache// 
 +    * ''​conda clean %%--%%all''​
  
-(base) >which python +==== Installation history ====
-/​home/​share/​unix_files/​cdat/​miniconda3/​bin/​python</​code>​+
  
-You probably don't want to type the //source// line each time you need to use your conda based python, so you can add a ''​source ​ ~jypeter/​.conda3_jyp.sh''​ line in your ''​~/​.bashrc''​ file, and ''​source ​ ~jypeter/​.conda3_jyp.csh''​ line in your ''​~/​.cshrc''​ file. Then, when you need a specific python environment,​ just type ''​conda activate name_of_the_specific_environment''​ 
  
 /* standard page footer */ /* standard page footer */
other/uvcdat/cdat_conda/miniconda3_install.txt · Last modified: 2024/04/25 14:24 by jypeter