Computational Environment on Mac OS

Set up Python on Mac OS

Mamba forge package

The best solution so far is to use MiniForge release. The Mamba Forge combination is the most efficient one. Download and run the Shell (.sh) installation file in Mac terminal. Use mamba init zsh to initialize Python for the terminal. zsh is the default shell for Mac OS. If a different shell is used, just change the parameter in mamba init. After doing this, it works just like the regular MiniConda. All the conda and package commands can be run in the initialized terminal.


# This will start conda automatically with zsh (default shell) on MacOS
conda init zsh
# Revserse the autostart. Or delete the lines from .zshrc in your home directory
conda init --reverse

# This can start the base conda environment
source ~/miniconda/bin/activate

# return back to the normal bash
conda deactivate

R and RStudio on MacOS

It is a pretty standard process as both have good support for MacOS with Intel or Apple Silicon chips. Just one common issue for R. By default, R packages are associated with specific versions. We can add a R_LIBS_USER environment variable to allow different versions of R share those packages so that we don’t have to re-install them when upgrading R from 4.4 to 4.5, for instance.

On Windows, we can just add R_LIBS_USER as a system or user environment variable. On MacOS, we can add a .Renviron file in our home directory and then add this line to the file.

R_LIBS_USER=~/R-libs/4.x

~ means your home directory, which can be replaced by /Users/[your user name]. Make sure the folder exists on the drive.


See also