Skip to the content.

Bash shell

You already have it! Depending on which version of Mac OS you’re running you may need to type bash inside the terminal to access it. To check whether this is necessary, follow these steps:

  1. Open a terminal and type echo $SHELL. If it reads /bin/bash then you are all set!

Note: If you are using Mac Catalina (10.15.X) or later, then it is possible your default shell is NOT CORRECT. To set the default to bash, type chsh -s /bin/bash in the terminal, enter your password when prompted, and then close + re-open the terminal.

Homebrew

Install the Homebrew package manager: open a terminal window, type this command, then press Enter:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Git

You may already have it! Try opening a terminal and typing git --version.

If this prints something like git version X.XX.X, git is already installed! If so, skip to the next section on “Git configuration”.

If git is not installed, then you might get a pop-up window prompting you to install the Xcode Command Line Tools, which we will not do: click “Cancel”. We will install git with Homebrew instead.

In the terminal, run:

brew install git

(If you already installed git through the Xcode Command Line Tools, that is fine, so you don’t need to worry.)

Verify the installation by running git --version: this time you should see something like git version X.XX.X.

Git configuration

If you have never used Git on your computer, you may have to configure it. The following instructions assume you have already created a GitHub account.

Type the following commands in a terminal. Make sure to use the email associated with your GitHub account. The user.name can be any name you want to appear as the author of your commits, but we recommend using the name associated with your GitHub profile.

git config --global user.name "Jane Doe"
git config --global user.email "janedoe@example.com"
git config --global core.autocrlf true

Tip: You can review your configuration at any time with: git config --list

Creating an SSH key for GitHub

When following the GitHub docs below, make sure to select the Mac instructions.

To authenticate to GitHub from the command line, you will use an SSH key pair, which is more secure than using your GitHub account password directly.

  1. In a terminal, check if you have existing SSH keys in the ~/.ssh directory. A public/private key pair typically has the filename format id_ALGORITHM and id_ALGORITHM.pub. If you have existing key files, use a custom name for your SSH key pair in step 2.
  2. Generate a new SSH key and add it to the ssh-agent.
    • Ensure to use the default file location for saving the key, unless you already have existing keys - in this case, replace just the id_ALGORITHM (e.g., id_ed25519) part of the file location with an informative keyname like id_ed25519_github
    • Choose a passphrase you can remember easily, as you will need to use it for certain Git commands
  3. Confirm your key pair was created by running the command:
    ls -la ~/.ssh
    You should see two files with your key name, one with .pub (the public key) and one without (the private key - do not share or copy this file!).
  4. Add the SSH key to your GitHub account.
    • Be careful when copying/pasting the public key to not accidentally add spaces or newlines
    • Choose Authentication Key for the key type
  5. Locally specify the SSH key to use when connecting to GitHub, so that the right "identity" is always used for local Git operations (useful when you have multiple keys).
    1. Run the following command (replace id_ed25519 with your private key's filename if you used a custom key name):
      printf 'Host github.com\n  User git\n  IdentityFile ~/.ssh/id_ed25519\n  IdentitiesOnly yes\n' >> ~/.ssh/config
    2. Then, check that the config was added:
      cat ~/.ssh/config
      You should see something like:
      Host github.com
        User git
        IdentityFile ~/.ssh/id_ed25519
        IdentitiesOnly yes
                

In this course, when using a Git command that prompts you for your passphrase, enter the passphrase you set for your private key in step 2.

VSCode

  1. Go to this page and click the download button.
  2. Unzip the downloaded file (for example, VSCode-darwin-universal.zip) and move the resulting Visual Studio Code file to your Applications directory.

VSCode extensions

  1. Open the Visual Studio Code application
  2. Type Cmd+Shift+P to open the “command palette” at the top of the screen and then enter Shell command: Install 'code' command in PATH. Select the highlighted entry. A notification box should appear in the bottom-right corner indicating that the command was installed successfully.
  3. Open the Extension side panel by pressing Cmd+Shift+X. In the search bar at the top of this panel search for each of the following extensions and press Install for the first entry that appears.
Required extensions

Python

  1. Open a new terminal and type the following command, then press Enter.
    • If you are on an Apple Silicon Mac (upper left corner Apple menu  -> About This Mac says something like “Chip: Apple M1” (or M2, etc.)):
       curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
      
    • Otherwise:
       curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
      
  2. Run the installation script:
    bash Miniconda3-latest-MacOSX-x86_64.sh
    
    • A license agreement will be displayed and the bottom of the terminal will read --More--. Press Enter or the space bar until you are prompted with “Do you accept the license terms? [yes|no].” Type yes and then press Enter
    • The installation script will inform you that it is going to install into a default directory (e.g., /Users/$USER/miniconda3). Leave this default and press Enter.
    • When you are asked “Do you wish the installer to initialize Miniconda3 by running conda init? [yes no],” type yes and press Enter.
    • Exit the terminal once the installation has finished.
  3. Re-open a terminal. Type which python into the terminal and it should return a path (e.g., /Users/$USER/miniconda3/bin/python).
    • If you do not see a path like this then please try typing conda init, closing your terminal, and repeating this step. If your issue is still not resolved. skip the following step and contact an instructor on the #help-installation channel of the QLS612-BHS Slack.
  4. Type the following to remove the installation script that was downloaded:

    rm ./Miniconda3-latest-MacOSX-x86_64.sh
    

Python packages

Open a terminal and type the following commands (press Enter after each):

conda config --append channels conda-forge
conda config --set channel_priority strict
conda create -n qlsc612 -y python=3.12 flake8 jupyterlab jupyter nilearn matplotlib seaborn bokeh statsmodels plotly wordcloud
conda activate qlsc612

This installation step (conda create) will take a couple minutes. The above commands create a new conda Python environment named qlsc612 with all the necessary packages installed for this course. The last line, conda activate qlsc612, will activate this Python environment (the default environment is base).

Docker

  1. Go to this page and press the button Docker Desktop for... corresponding to the chip of your machine (see the image below).

  2. Open the Docker.dmg file that is downloaded and drag and drop the icon to the Applications folder.

  3. Open the Docker application and enter your password. An icon will appear in the status bar in the top-left of the screen. Wait until it reads Docker Desktop is now up and running!

  4. Open a new terminal and type docker run hello-world. A brief introductory message should be printed to the screen.

The above step-by-step Docker instructions are distilled from here. If you have questions during the installation procedure please check that link for potential answers!