Reputation: 3838
I have installed conda using miniforge. Since my mac has a m1 chip, i had to install conda using Miniforge3-MacOSX-arm64.sh
, inorder to get tensorflow working. unfortunately this version (minforge/minconda arm64) doesn't have python2 for some reason. As I require python2 for another project (doesnot require tensorflow) I have decided to install anaconda3.
But now I am unaware how to switch between the two conda versions (anaconda3 and miniconda/miniforge3).
For example when I enter activate conda
in the terminal, it activates the base
environment of the miniforge version.
How do I activate base
environment of the anaconda version. So that I can create python2 environment there (anaconda3).
Upvotes: 9
Views: 23249
Reputation: 147
Based on @manciacci 's answer,
Change the existing .zshrc like below you only have to change CONDA_PATH
in your .zshrc file. After that, you may have to do conda activate
in a new shell.
CONDA_PATH_1=miniconda3
CONDA_PATH_2=miniforge3
CONDA_PATH=${CONDA_PATH_1}
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/username/${CONDA_PATH}/bin/conda' 'shell.zsh' 'hook' 2>
/dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/username/${CONDA_PATH}/etc/profile.d/conda.sh" ]; then
. "/home/username/${CONDA_PATH}/etc/profile.d/conda.sh"
else
export PATH="/home/username/${CONDA_PATH}/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
Upvotes: 2
Reputation: 193
A quick fix for switching between environments is to pick out the path you get from the output of conda env list
. Here is what I get from both miniforge and miniconda:
(base) user@machine script % conda env list
# conda environments:
#
base * /Users/user/miniforge3
nmgp /Users/user/miniforge3/envs/nmgp
scphere /Users/user/miniforge3/envs/scphere
/opt/miniconda3
/opt/miniconda3/envs/gpcounts
/opt/miniconda3/envs/gpy
/opt/miniconda3/envs/test
/opt/miniconda3/envs/nmgp
/opt/miniconda3/envs/scphere
/opt/miniconda3/envs/ssdgp
To activate the miniforge environments you can use the name directly:
conda activate nmgp
To activate a miniconda environment you can use the absolute path:
conda activate /opt/miniconda3/envs/nmgp
Upvotes: 5
Reputation: 86
According to this post, one solution is to change the content of your .zshrc file, save your changes, close and reopen your terminal. I tested on a MacBook Pro M1 where Miniforge3 and Anaconda3 are currently installed and it works. In the following, just replace --PATH-- with the path of the requested environment management system. For example, I replace --PATH-- with opt/anaconda3 for Anaconda3 and miniforge3 for .. Miniforge3.
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/username/--PATH--/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/username/--PATH--/etc/profile.d/conda.sh" ]; then
. "/Users/username/--PATH--/etc/profile.d/conda.sh"
else
export PATH="/Users/username/--PATH--/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
Upvotes: 7