1  macOS Environment

In this tab, we provide steps to install a data science environment on a computer running the macOS operating system.

For a series of walk through videos, please see:

https://www.youtube.com/watch?v=CnKpOwAFeIE&list=PL50Yqb_ZFDedUXLKmzMDdDiuFGEdokuck&index=1

Many readers may already have a Python installation on their computer. However, the installation may be outdated, missing packages, or incorrectly setup. Thus, we highly recommend re-installing the Python by following the guide below.

Please do not follow these instructions if you are on a Windows computer! Please select the Windows Environment Setup Guidelines.

1.1 Installing Xcode Command Line Tools (Xcode CLI) on macOS

Video depicting the steps to install Xcode Command Line Tools (Xcode CLI)

First, we need to install Xcode CLI developer tools by:

  1. Opening Terminal
    • Found under Applications -> Utilities -> Terminal.app;
    • Or, by typing in “Spotlight” in the upper right-hand corner Terminal.
  2. Once Terminal is open type:
sudo xcode-select --install
  1. This will trigger an installation pop-up. Please follow the installer prompts.

  2. To verify the success of the installation, type into Terminal:

git --version

1.2 Setting up Git

Introducing Yourself to Git Version Control System on macOS with Terminal

While in Terminal, setup git by typing:

git config --global user.name "FirstName LastName"
git config --global user.email netid@illinois.edu

where FirstName and LastName correspond to your full name and netid@illinois.edu should be your Illinois e-mail address.

1.3 Installing Miniconda 3 on macOS

Next, we need to download and install Miniconda 3. We can approach the installation by either using the Terminal Installer or an Installer Package.

Important

Please follow either the Terminal Installer or Installer Package approach. Do not perform both installation routines!

Downloading and Installing Miniconda 3 on macOS using Terminal

We will aim to install Miniconda 3 by using the terminal to handle the installation.

Please do the following:

  1. Opening Terminal
    • Found under Applications -> Utilities -> Terminal.app;
    • Or, by typing in “Spotlight” in the upper right-hand corner Terminal.
  2. Depending on the Mac’s hardware, please select the appropriate installer:

If you have an Intel-based Mac, please use the Miniconda3-latest-MacOSX-x86_64.sh installer.

If you are using an ARM-based mac (M1, M2, …), the Intel-based version will work using emulation via Rosetta2. However, this may cause issues down the line. Thus, we recommend using the ARM-specific software. Please select Miniconda3-latest-MacOSX-arm64.sh.

Intel-powered Macs or Macs purchased before 2020

# Download the installer bash script for Intel Macs (any Macs before 2020) by:
curl -sL \
"https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" > \
"Miniconda3.sh"

# Then, run the installer script by using:
bash Miniconda3.sh

Arm64-powered (M1, M2, etc.) Macs or Macs purchased during during or after 2020

# Download the installer bash script for arm64 Macs (any Macs post 2020) by:
curl -sL \
"https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh" > \
"Miniconda3.sh"

# Then, run the installer script by using:
bash Miniconda3.sh
  1. Ensure that conda was installed correctly and is up-to-date by typing:
conda update -n base -c defaults conda

We will aim to install Miniconda 3 by using an installer package (.pkg) to handle the installation.

If you have an Intel-based Mac, please use the Miniconda 3 MacOSX 64-bit pkg installer.

If you are using an ARM-based mac (M1, M2, …), the Intel-based version will work using emulation via Rosetta2. However, this may cause issues down the line. Thus, we recommend using the ARM-specific software. Please select Miniconda 3 MacOSX arm64 pkg.

  1. Visit https://docs.conda.io/en/latest/miniconda.html.
  2. Depending on the Mac’s hardware, please select either:
  3. Open the downloaded installer.
  4. Follow the steps to completion.
  5. Open Terminal
    • Found under Applications -> Utilities -> Terminal.app;
    • Or, by typing in “Spotlight” in the upper right-hand corner Terminal.
  6. Ensure that conda was installed correctly and is up-to-date by typing:
conda update -n base -c defaults conda

1.4 Installing the pre-defined conda Data Science environment on macOS

Downloading and Installing the Data Science (ds) conda Environment on macOS with Terminal

With the software prerequisites done, we will now download the configuration files needed to setup the data science environment.

# Download the Conda environment file
curl -Os \
"https://raw.githubusercontent.com/coatless-textbooks/sds/master/ds.yaml" 

# Download the pip requirements file to filter software
curl -Os \
"https://raw.githubusercontent.com/coatless-textbooks/sds/master/requirements-ds.txt" 

Finally, we will install the ds environment for the course by typing:

# Create an environment called "ds" with packages installed.
conda env create -f ds.yaml

1.5 Using the Data Science (ds) Environment

Once done, the ds conda environment can be used by typing in Terminal:

# Change from "base"/global into ds environment
conda activate ds

To return to the global environment, type in Terminal:

# Return to "base"/global environment
conda deactivate

  1. The URL for the latest Miniconda 3 Intel (x86_64) is: https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.pkg↩︎

  2. The URL for the latest Miniconda 3 M1 or M2 (arm64) is: https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.pkg↩︎