6

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

imantha
  • 2,676
  • 4
  • 23
  • 46
  • I have a very similar situation whereby I need to have just miniforge but with the ability to tweak it to install the packages I want including non-arm versions or a way to have anaconda3 AND miniforge coexist on my mac. Did you figure out a solution? – djeetee Jun 08 '21 at 12:56

2 Answers2

6

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 <<<
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Thanks for the answer, now i encounter the same issue, but can you explain which path. every answer is talking about path, is that Export Path that I need to change? and where to change ? – Irfan Yaqub Feb 01 '23 at 17:42
  • 1
    Open your .zshrc file with a text editor, locate the conda section that starts with `# >>> conda initialize >>>`, then for the next 4 lines : `__conda_setup="$('/Users/username/--PATH--/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"` | `if [ -f "/Users/username/--PATH--/etc/profile.d/conda.sh" ]; then` | `. "/Users/username/--PATH--/etc/profile.d/conda.sh"` | `export PATH="/Users/username/--PATH--/bin:$PATH"` | replace --PATH-- with `opt/anaconda3` or `miniforge3` to enable anaconda or miniforge, respectively. – Manicacci François-Marie Feb 02 '23 at 19:06
5

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
Njw96
  • 83
  • 3
  • 12