How can I create a script to switch between my ARM conda and x84 conda?

Solution 1:

So far, the best solution I've found is to start the terminal with Rosetta 2, then run a function I have saved in .zshrc to initialize the correct conda installation so that I can use the correct architecture for my needs depending on the situation.

My current solution is the following function named x86:

x86 () {

conda deactivate

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/$USERNAME/miniforge3_x86_64/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/$USERNAME/miniforge3_x86_64/etc/profile.d/conda.sh" ]; then
        . "/Users/$USERNAME/miniforge3_x86_64/etc/profile.d/conda.sh"
    else
        export PATH="/Users/$USERNAME/miniforge3_x86_64/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

export PATH="/Users/$USERNAME/miniforge3_x86_64/bin:$PATH" 
export PATH="/Users/$USERNAME/miniforge3_x86_64/condabin:$PATH"
}

I am still feeling this out. I may add some aliases within the function as well so things like pip do not conflict, but I hope that by prepending the x86 paths the correct packages will be referenced