Conda activate doesn't work in bash file

I’ve installed Qiime2 2020.8 in a conda environment and followed all the steps on https://docs.qiime2.org/2020.8/install/native/#install-qiime-2-within-a-conda-environment. When I activate Qiime2 in the terminal (using conda activate qiime2-2020.8) all goes well, but when I try to run this command from within a bash file, it gives me an error message saying

CommandNotFound: Your shell has not been properly configured to use ‘conda activate’.
To initialize your shell, run
$ conda init {SHELL_NAME}

When I do this, there is no action taken, implying it should all be fine. Again, this works for activating in the shell, but not for activating in a bash file. Does anyone know how to solve this? Thanks in advance!

1 Like

Hello @aliciaocke. Try using source activate qiime2-2020.8 instead of conda activate qiime2-2020.8 in your bash script. If that doesn’t work, try add the line source ~/miniconda3/etc/profile.d/conda.sh before your conda activate. Thank you.

3 Likes

This worked for me, thanks! I also removed the bash extention from the file in order to make this work, in case other people also didn’t know conda activate doesn’t work in bash files.

2 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.