conda activate not working in a bash file

Solution 1:

Either

  1. Add eval $(conda shell.bash hook) to your script, or
  2. Call your script with bash -i to invoke your interactive environment

Solution 2:

Another answer, given in this question that worked for me on this error message was:

source activate base

So a full example could be:

#!/bin/bash
conda create --name myenv1
source activate base 
conda activate myenv1