Ubuntu – When using conda, “source activate [env_name]” doesn’t work but “conda activate [env_name]” works

condapython

I have been using conda for a few months. The following is the version that I'm using:

conda -V
conda 4.5.4

Previously, to activate or to deactivate the conda environment, I think I have used the following command:

source activate [env_name]
source deactivate

However, recently, the above commands don't work on my machine for unknown reason. The following is the result:

bash: activate: No such file or directory

More strangely, the following commands work:

conda activate [env_name]
conda deactivate

Could you suggest what might have happened and how to fix this problem?

Best Answer

The problem may be because the Anaconda directory is not part of your PATH. You can check this by entering the following command in your terminal. If you don't see the Anaconda directory(Looks something like this /home/user/anaconda3/bin), you found your issue!

echo $PATH

To fix this problem, you can simply enter the following command in the terminal where user is your username.

export PATH="/home/user/anaconda3/bin:$PATH"

If this helped, please mark this as an accepted answer so that your original question can be marked as solved!