I'm trying to activate a conda environment on a cluster. However, I keep being returned with the shell needing to be initialized. Ruuning conda init bash does nothing and even when closing the shell and trying again I get the same 'conda is not initialized'?

-bash-4.2$ conda activate libraries/CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.To initialize your shell, run$ conda init <SHELL_NAME>Currently supported shells are:- bash- fish- tcsh- xonsh- zsh- powershellSee 'conda init --help' for more information and options.IMPORTANT: You may need to close and restart your shell after running 'conda init'.-bash-4.2$ conda init bashno change /usr/local/miniconda3/condabin/condano change /usr/local/miniconda3/bin/condano change /usr/local/miniconda3/bin/conda-envno change /usr/local/miniconda3/bin/activateno change /usr/local/miniconda3/bin/deactivateno change /usr/local/miniconda3/etc/profile.d/conda.shno change /usr/local/miniconda3/etc/fish/conf.d/conda.fishno change /usr/local/miniconda3/shell/condabin/Conda.psm1no change /usr/local/miniconda3/shell/condabin/conda-hook.ps1no change /usr/local/miniconda3/lib/python3.8/site-packages/xontrib/conda.xshno change /usr/local/miniconda3/etc/profile.d/conda.cshno change /nethome/6966225/.bashrcNo action taken.-bash-4.2$ conda activate libraries/CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.To initialize your shell, run
1

Best Answer


The lack of changes is likely because you previously already ran conda init and the changes have been made already - that is, Conda will only show this if it finds the initialization code is present. Have a look at your ~/.bashrc file to check if there is a Conda initialization section.

The conda init command only updates the shell initialization files (e.g., .bashrc) to include shell function setup. One still needs to source the relevant initialization file. Typically, this is done by restarting the shell session or running . ~/.bashrc.

Be aware that the shell also needs to be launched in a way that it loads the relevant initialization file. Most user-initiated shell sessions do this automatically, but in some situations one may need to explicitly include a flag for interactive (-i in bash) or login (-l in bash) sessions to ensure loading of .bashrc or .bash_profile files.