As of 2019, Amit Singh's comment is slightly out of date (and the link is broken). I had the same issue previously, but needed to install conda to work on a specific project with a collaborator. I did this using miniconda, but it should work with Anaconda as well.
After installing conda, this is added to ~/.bash_profile (or .bashrc):
added by Miniconda3 4.5.12 installer
>>> conda init >>>
!! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/<user>/miniconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/<user>/miniconda3/etc/profile.d/conda.sh" ]; then
. "/Users/<user>/miniconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/<user>/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
<<< conda init <<<
It basically automatically activates a base conda environment and puts you in it when you start a new shell. This adds conda's python, and other software, to your path. Any tools looking for system/homebrew install programs such as python will get the conda versions instead if they exist. This can create problems if you are trying to use the homebrew versions of things.
This whole block can be safely deleted. Instead, add:
. /Users/<user>/miniconda3/etc/profile.d/conda.sh
to you ~./bash_profile. This calls a script which creates bash functions for conda, conda activate, and conda deactivate and sets some environment variables. Importantly, it doesn't active the base environment (the default, global conda environment) or change your path.
You can now create a conda environment for your project and install whatever you need into that:
conda create -n my_project python R jupyter # Whatever packages you need
conda activate my_project
# do some stuff
conda deactivate # leave the environment
# do unrelated stuff without issues
If you do want to use the default (root) environment, it can be activated like any other:
conda activate root
# do some stuff
conda deactivate
I hope that helps!