Conda/Mamba tips and tricks: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
== Unable to activate environment - even after ‘conda init’ and re-login to the shell ==
<syntaxhighlight lang="bash">
$ source activate base
$ conda deactivate
$ conda activate <env name>
</syntaxhighlight>


== Update Python version for the conda env using mamba and yaml file ==
== Update Python version for the conda env using mamba and yaml file ==

Revision as of 10:13, 18 February 2025

Unable to activate environment - even after ‘conda init’ and re-login to the shell

$ source activate base
$ conda deactivate
$ conda activate <env name>

Update Python version for the conda env using mamba and yaml file

# environment.yml to update package inside of your environment
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python >=3.10,<3.11
  - jupyterlab
  - numpy
  - scikit-learn
  - matplotlib-base # avoid qt if you can, if having trouble

$mamba env update -n <your env> --file environment.yml

Basic conda/mamba env setup in DLS framework

conda config --set auto_activate_base false
conda config --add channels r
conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge

conda: error: argument COMMAND: invalid choice: 'actiate'

# Try activate base 
$ source activate base
# Then deactivate it
(base) $ conda deactivate

# after then you can use activate command
$ conda activate base

Downgrading Conda Version

conda config --set allow_conda_downgrades true
conda install conda=a.b.c   # version you want to install

Speedup Conda

This page describes how to speed up conda operation

some examples are,

conda config --add channels bioconda

conda config --set channel_priority strict

conda config --set safety_checks disabled

Conda commands

Commands Description Options Notes
conda update conda update the conda package manager to the latest version
conda update anaconda use conda to update Anaconda to the latest version
conda install anaconda=VERSION-NUMBER use conda to install a specific version of Anaconda
conda config --add channels conda-forge Add conda channel Update channels section of ~/.condarc file
conda config --set channel_priority strict Set channel priority policy
conda config --show-sources Show config status
conda update --all --verbose Update all conda with printout
conda list --show-channel-urls Listup conda channels
conda search -f python search available python version Search can be extened with channels$ cat ~/.condarcchannels:- conda-forge- bioconda- defaults Conda only has support for Python 3.8+ on the osx-arm64[1]

To search alternative platforms, can use the --subdir, --platform argument to specify,

$conda search --subdir osx-64 python=3.6 or set the subdir configuration temporarily through the CONDA_SUBDIR environment variable:

CONDA_SUBDIR=osx-64 conda search python=3.6

Reference