There are a number of use cases for which I am trying to use conda
. The main headache is that conda init
just does not want to play fair within the flow of a script in the same bash shell. I frequently see
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
That happens even though the contents of the conda initialize script as well as conda init
have been executed. The results are inconsistent: sometimes I have seen the init logic work, others not. I have not been able to ascertain what magic is happening and what it expects in order to work properly..
conda_init() {
# __conda_setup="$('$CONDA_DIR/bin/conda' 'shell.bash' 'hook' 2> /dev/null)";
source $CONDA_DIR/etc/profile.d/conda.sh
export PATH="$CONDA_DIR/condabin:$CONDA_DIR/bin:$PATH";
export CONDARC=$CONDA_DIR ;
conda init bash
}
conda_init
conda activate py38
That gives us
/Users/steve/opt/miniconda3/bin/conda
/Users/steve/opt/miniconda3/bin::/Users/steve/opt/miniconda3/condabin:<other stuff..>
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
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
How can that conda_init()
be made reliable for being able to run conda init
in the same shell?