Both sides previous revisionPrevious revisionNext revision | Previous revision |
other:uvcdat:cdat_conda:miniconda3_install [2024/07/03 11:44] – [Useful conda commands] Started improving the repoquery section jypeter | other:uvcdat:cdat_conda:miniconda3_install [2024/08/09 17:42] (current) – Added a new "Creating Windows menu shortcuts to start environments" section jypeter |
---|
* ''Anaconda Prompt'' | * ''Anaconda Prompt'' |
* ''Anaconda Powershell Prompt'' | * ''Anaconda Powershell Prompt'' |
* **We will now use this //Anaconda PowerShell// shortcut each time we need to use Miniconda3 or Python** | * **We will now use this //Anaconda Powershell// shortcut each time we need to use Miniconda3 or Python** |
| * It is **highly recommended to [[other:win10apps#windows_terminal|install Windows Terminal and make it the default terminal application]]**, so that the ''conda'' prompts will open in a modern (and highly configurable) terminal |
| |
* Remove the installer<code>PS C:\Scratch\your_login> del .\miniconda.exe</code> | * Remove the installer<code>PS C:\Scratch\your_login> del .\miniconda.exe</code> |
| |
<WRAP center round important 60%> | <WRAP center round important 60%> |
It seems safe to reclaim some disk space by cleaning up the initial (//base//) installation.\\ \\ Use cleaning with caution after installing other environments... | It seems **safe** to reclaim some disk space by cleaning up the initial (//base//) installation, **when no other (shared) environments have been installed yet**\\ \\ Use cleaning with caution after installing other environments (besides ''base''), especially environments **shared** by several users. But it should not break your installation |
</WRAP> | </WRAP> |
| |
You can [[https://docs.conda.io/projects/conda/en/latest/commands/clean.html|clean]] the initial //Miniconda3// installation to free up some disk space. | * ''conda clean %%--%%all'' |
| * [[https://docs.conda.io/projects/conda/en/latest/commands/clean.html|Documentation]] |
The documentation specifies //WARNING: This will break environments with packages installed using symlinks back to the package cache.//\\ **You should probably avoid using ''clean'' once you have used //Miniconda3// to install new Python environments** (unless you are desperate for disk space, and know how to do a complete re-installation if something breaks...) | * There is **no ''-n'' option to specify an environment name**, because ''clean'' will //Remove **unused** packages and caches// shared by **all** the environments |
| * The ''clean'' command will mostly deal with the content of the ''/path_to_miniconda/pkgs/'' directory |
<code>(base) $ conda clean --all | * Example:<code>(base) $ conda clean --all |
Will remove 154 (180.9 MB) tarball(s). | Will remove 154 (180.9 MB) tarball(s). |
Proceed ([y]/n)? y | Proceed ([y]/n)? y |
457M /homedata/jypmce/miniconda3_2024-03 | 457M /homedata/jypmce/miniconda3_2024-03 |
</code> | </code> |
| |
| * It //should// be safe to use ''conda clean %%--%%all'' even in a multi-user installation with several environments, **if you don't use the ''-f'' option** |
| * The ''-f''/''%%--%%force-pkgs-dirs'' documentation specifies //WARNING: This will break environments with packages installed using symlinks back to the package cache.// |
| * ...but Linux installations probably use [[https://www.redhat.com/sysadmin/linking-linux-explained|hard links]] rather than soft/symbolic links |
| * ...and you will probably never need this option anyway |
| |
| * Remember that **your Python installation will keep on growing and growing and growing, and you will need to do some cleaning at some point** |
| |
| |
| |
===== Initializing conda in terminals ===== | ===== Initializing conda in terminals ===== |
| |
* FIXME: update/rewrite the [[other:uvcdat:cdat_conda:cdat_2024_03]] page | * FIXME: update/rewrite the [[other:uvcdat:cdat_conda:cdat_2024_03]] page |
| |
| |
| ===== Creating Windows menu shortcuts to start environments ===== |
| |
| FIXME => Move this section somewhere else? |
| |
| * Use ''conda install'' and what is described in [[https://github.com/conda/menuinst/issues/246|Easily creating shortcuts with the powershell_shortcut_miniconda and console_shortcut_miniconda packages, and can this be replicated with menuinst ?]] |
| |
| * Can theoretically be done with [[https://conda.github.io/menuinst/|menuinst]] |
| * [[https://github.com/conda/menuinst|menuinst @ GH]] |
| |
| * FIXME Find a way to add Windows Terminal profiles |
| * See ''menuinst''+[[https://github.com/conda/menuinst/issues/196|Add Windows Terminal profile option]] |
===== conda resources ===== | ===== conda resources ===== |
| |
==== Web sites ==== | ==== Web sites ==== |
| |
* [[https://docs.conda.io/projects/conda/en/stable/|Official conda website]] | * [[https://docs.conda.io/projects/conda/en/stable/|Official Documentation site]] |
* [[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/user-guide/cheatsheet.html|Cheat sheet]] (2 pages, for people in a hurry) |
* [[https://docs.conda.io/projects/conda/en/stable/commands/|Commands' reference]] | * [[https://docs.conda.io/projects/conda/en/stable/commands/|Commands' reference]] |
| * [[https://docs.conda.io/projects/conda-build/en/stable/resources/package-spec.html#conda-package-specification|Conda package specification]] |
| * This helps understand (and [[https://github.com/conda/conda/issues/14026|use]]) the content of the ''/path_to_miniconda/pkgs'' directory |
| |
| * [[https://conda.org/blog/|conda community site]]: |
| * [[https://conda.org/blog/|conda Blog]]: ''conda'' new features, etc... |
| |
| * [[https://github.com/conda/conda|conda @ GitHub]] |
| |
* Package repositories | * Package repositories |
* [[https://conda-forge.org/packages/|conda-forge]] <= recommended source of packages | * [[https://conda-forge.org/packages/|conda-forge]] <= recommended source of packages |
* **Specific versions can be specified** by using the [[#the_conda_matchspec_format|conda MatchSpec format]] | * **Specific versions can be specified** by using the [[#the_conda_matchspec_format|conda MatchSpec format]] |
* ''conda remove package1 package2 packageN'' | * ''conda remove package1 package2 packageN'' |
| * Matching ''pip'' commands (**only** if the package is not available in conda!) |
* Display the **dependencies of a package**, and the **packages that need a specific packages** | * ''pip install package'' |
* e.g. the ''requests'' package | * ''pip uninstall package'' |
| |
* **Update a package** in the current, or a specific environment | * **Update a package** in the current, or a specific environment |
* ''conda update -n existing_environment installed_package'' | * ''conda update -n existing_environment installed_package'' |
* Update only the ''conda'' package (not the full Miniconda3 //base// environment) in the ''base'' environment\\ ''conda update -n base conda'' | * Update only the ''conda'' package (not the full Miniconda3 //base// environment) in the ''base'' environment |
| * ''conda update -n base conda'' |
| * Changes and new ''conda'' features are detailed in the [[https://conda.org/blog/|conda Blog]] |
| * Matching ''pip'' command (**only** if the package is not available in conda!) |
| * ''pip install %%--%%upgrade package'' |
| |
* **Completely update an environment** (i.e. update **all** the packages) | * **Completely update an environment** (i.e. update **all** the packages) |
* Note: ''mamba repoquery'' currently [[https://github.com/mamba-org/mamba/issues/3334|only works in the currently active environment]] | * Note: ''mamba repoquery'' currently [[https://github.com/mamba-org/mamba/issues/3334|only works in the currently active environment]] |
* It can be useful to determine: | * It can be useful to determine: |
* the packages that are required in order to use a given package => ''depends'' | * the packages that are required in order to use a given package => ''mamba repoquery **depends** package'' |
* the packages that need a given package => ''whoneeds'' | * Without ''mamba repoquery depends'', you would have to follow the steps in [[https://docs.conda.io/projects/conda/en/stable/user-guide/tasks/manage-pkgs.html#listing-package-dependencies|Listing package dependencies]] :-( |
| * the packages that need a given package => ''mamba repoquery **whoneeds** package'' |
* Example: the ''[[https://github.com/tqdm/tqdm|tqdm]]'' package | * Example: the ''[[https://github.com/tqdm/tqdm|tqdm]]'' package |
* ''conda'' needs ''tqdm'' to display package download and installation progress, and the base dependencies of ''tqdm'' are [[https://github.com/tartley/colorama|colorama]], and of course ''python'' | * ''conda'' needs ''tqdm'' to display package download and installation progress, and the base dependencies of ''tqdm'' are ''[[https://github.com/tartley/colorama|colorama]]'', and of course ''python'' |
| * Detailed use:<code> >mamba repoquery whoneeds --pretty tqdm |
| tqdm |
| └─ conda[24.5.0] |
| |
| >mamba repoquery depends --pretty tqdm |
| tqdm[4.66.4] |
| ├─ colorama[0.4.6] |
| └─ python[3.12.3] |
| </code> |
| * The packages that ''tqdm'' needs also need packages, and so on...<code> >mamba repoquery depends --tree tqdm |
| tqdm[4.66.4] |
| ├─ colorama[0.4.6] |
| │ └─ python[3.12.3] |
| │ ├─ bzip2[1.0.8] |
| │ │ └─ libgcc-ng[14.1.0] |
| │ │ ├─ _libgcc_mutex[0.1] |
| │ │ └─ _openmp_mutex[4.5] |
| │ │ ├─ _libgcc_mutex already visited |
| │ │ └─ libgomp[14.1.0] |
| │ │ └─ _libgcc_mutex already visited |
| │ ├─ libgcc-ng already visited |
| │ ├─ ld_impl_linux-64[2.40] |
| │ ├─ libexpat[2.6.2] |
| │ │ └─ libgcc-ng already visited |
| [...] |
| </code> |
| |
| * **Checking the //health// of an environment** with ''[[https://docs.conda.io/projects/conda/en/stable/commands/doctor.html|conda doctor]]'' |
| * Some details in [[https://conda.org/blog/2023-06-01-conda-doctor/|Detecting conda environment inconsistencies easily]] |
| * ''conda doctor'' does not do much yet, and not necessarily in a useful way, but this will hopefully improve over time! |
| * [[https://github.com/conda/conda/issues/14017|'conda doctor' output should be improved]] |
| * [[https://github.com/conda/conda/issues/13574#issuecomment-2214291304|What exactly are altered files?]] |
| * ''conda doctor -n base'' |
| * Example:<code> >conda doctor -n base |
| Environment Health Report for: /home/share/unix_files/cdat/miniconda3_2024-03 |
| |
| Altered Files: |
| |
| python-3.12.3-hab00c5b_0_cpython: 1 |
| |
| Environment listed in environments.txt file: ✅ |
| |
| Missing Files: |
| |
| ✅ There are no packages with missing files. |
| </code> |
| |
* **Cleaning... <wrap em>Dangerous</wrap>**! | * **Cleaning...** |
* ''conda'' does not automatically clean the content of the ''pkgs'' directory | * ''conda'' does not automatically clean the content of the ''/path_to_miniconda/pkgs'' directory and the size of ''/path_to_miniconda/'' will keep on growing, as you add new environments, or update existing ones |
* If you have several environments, ''conda clean'' may remove packages that are not needed in an environment, but are still used in other environments, and **you may end up with a broken installation...** | * All the details are in the [[#cleaning_up_miniconda3|Cleaning up Miniconda3...]] section |
* More details in [[#cleaning_up_miniconda3|Cleaning up Miniconda3...]] | |
| |
| |
* Read the [[https://docs.conda.io/projects/conda/en/stable/commands/#conda-vs-pip-vs-virtualenv-commands|Conda vs. pip vs. virtualenv commands]] section | * Read the [[https://docs.conda.io/projects/conda/en/stable/commands/#conda-vs-pip-vs-virtualenv-commands|Conda vs. pip vs. virtualenv commands]] section |
| |
* Read the [[https://docs.conda.io/projects/conda/en/stable/user-guide/tasks/manage-environments.html#using-pip-in-an-environment|Using pip in an environment]] | * Read the [[https://docs.conda.io/projects/conda/en/stable/user-guide/tasks/manage-environments.html#using-pip-in-an-environment|Using pip in a conda environment]] |
| * //Issues may arise when using pip and conda together//... |
==== Installation history ==== | ==== Installation history ==== |
| |
FIXME | FIXME |
| |
| |
| ===== Improving conda and related tools ===== |
| |
| There is always room for improvement, and this is is some kind of //TODO// section |
| |
| ==== conda and mamba ideas ==== |
| |
| * [[https://github.com/conda/conda/issues/14026|Add a conda command to find the package owning a file]] |
| * The link also shows how to do it with standard Linux tools (find, grep), based on the [[https://docs.conda.io/projects/conda-build/en/stable/resources/package-spec.html#conda-package-specification|Conda package specification]] page |
| * [[https://github.com/kelvinou01/conda-which|conda-which]] seems to work (see [[https://github.com/conda/conda/issues/14026#issuecomment-2268821608|test / example]]) ! |
| |
/* standard page footer */ | /* standard page footer */ |