'Switch between anaconda and miniconda (miniforge)

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).



Solution 1:[1]

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 <<<

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman
Solution 2 Njw96