Follow the instructions on this page in order to install all the software that you will need for this class.

Table of contents
  1. Overview
  2. Setup
    1. The Bash Shell
      1. Windows
      2. macOS
      3. Linux
      4. ChromeOS
        1. Terminal
        2. Installing missing packages with apt-get
    2. Git
      1. Windows
      2. macOS
      3. Linux
      4. ChromeOS
    3. Text Editor
      1. Windows
      2. macOS
        1. Install Visual Studio Code for macOS
        2. Install the code command for VS Code
      3. Linux
      4. ChromeOS
    4. Python
      1. Windows
        1. Windows anaconda installation
        2. Modify Git Bash startup file for anaconda
      2. macOS
      3. Linux
      4. ChromeOS
        1. Install miniconda
        2. Install Python packages for the class
  3. Testing
    1. Bash shell
    2. Git
    3. editor (Visual Studio Code)
      1. First time
      2. From the shell
    4. Python
      1. python interpreter
      2. Jupyter notebook
      3. Common problems
  4. Credits
  5. Footnotes

Overview

You will need to install

  1. The Bash Shell
  2. Git
  3. a text editor (by default, Visual Studio Code / code)
  4. Python (including a number of additional packages required for scientific computing)

In each section, find the instructions for your operating system (Windows, macOS, or Linux).

Once you have installed everything, test your installation.

Setup

To participate in a the class, you will need access to the software described below. In addition, you will need an up-to-date web browser.

If you encounter problems during the installation ask an instructor for help. We also maintain resources for trouble shooting problems during the installation

The Bash Shell

Bash is a commonly-used shell that gives you the power to do simple tasks more quickly.

Windows

For Windows, we install the bash shell together with the git version control software:

  1. Download the Git for Windows installer.
  2. Run the installer and follow the steps below:
    1. Click on "Next" four times (two times if you've previously installed Git). You don't need to change anything in the Information, location, components, and start menu screens.
    2. From the dropdown menu, "Choosing the default editor used by Git", select "Use the Nano editor by default" (NOTE: you will need to scroll up to find it) and click on "Next".
    3. On the page that says "Adjusting the name of the initial branch in new repositories", ensure that "Let Git decide" is selected.
    4. Ensure that "Git from the command line and also from 3rd-party software" is selected and click on "Next". (If you don't do this Git Bash will not work properly, requiring you to remove the Git Bash installation, re-run the installer and to select the "Git from the command line and also from 3rd-party software" option.)
    5. Select "Use bundled OpenSSH".
    6. Ensure that "Use the native Windows Secure Channel Library" is selected and click on "Next".
    7. Ensure that "Checkout Windows-style, commit Unix-style line endings" is selected and click on "Next".
    8. Ensure that "Use Windows' default console window" is selected and click on "Next".
    9. Ensure that "Default (fast-forward or merge) is selected and click "Next".
    10. Ensure that "Git Credential Manager" is selected and click on "Next".
    11. Ensure that "Enable file system caching" is selected and click on "Next".
    12. Click on "Install".
    13. Click on "Finish" or "Next".

This will provide you with both Git and Bash in the Git Bash program.

If your "HOME" environment variable is not set (or you don't know what this is):

  1. Open command prompt (Open Start Menu then type cmd and press Enter).
  2. Type the following line into the command prompt window exactly as shown:
            setx HOME "%USERPROFILE%"
            
  3. Press Enter, you should see SUCCESS: Specified value was saved.
  4. Quit command prompt by typing exit then pressing Enter.

macOS

You can access Bash from the Terminal (found in /Applications/Utilities). You may want to keep Terminal in your dock for this class.

Recent versions of macOS (starting with Catalina 10.15) ship wth zsh as the default shell but also have Bash installed. You can either type bash in the terminal to switch to Bash or change permanently to Bash by executing the following command in the terminal:

chsh -s /bin/bash

(and enter your password when asked).

In earlier versions, the default shell is Bash, so no need to install or change anything.

Linux

The default shell is usually Bash, but if your machine is set up differently you can run it by opening a terminal and typing bash. There is no need to install anything.

ChromeOS

ChromeOS is the operating system from a Chromebook.

In order to install software for the class on a Chromebook you need to first enable the Linux system on the Chromebook, following the instructions below. (You can check How to enable Linux on your Chromebook (and why you should) to enable Linux.) This will, amongst other things, install the Bash shell.

We found that you can enable Linux on Chromebook, and it will just work as a Linux system. Please follow the instructions to enable Linux, which can be summarized as:

  1. open your system’s Settings
  2. look for Linux (Beta) on the sidebar
  3. turn on Linux support: Follow the instructions on screen to configure the Linux environment (for most people, accepting the default values should be enough). Your Chromebook will then download the tools to create the Linux environment and configure it for you.
  4. Once the Linux environment has been set up, you’ll see a new terminal window popping up.
  5. In the Terminal, run the following commands to install some needed Linux packages
    sudo apt-get update
    sudo apt-get install -y gnome-keyring
    
Terminal

Terminal is an application in the Linux folder that gives you access to the command line. It runs the bash shell (which is what we need for the class).

Keep a shortcut for Terminal handy.

(You can also run Terminal inside VS Code although we commonly open it as a separate application.)

Installing missing packages with apt-get

apt-get is the package manager that knows where to find software packages and how to install them.

If you later find that something is missing, you can install it with

sudo apt-get install PACKAGE_NAME

where PACKAGE_NAME is the name of the package (e.g., “git”).

Git

Git is a version control system that lets you track who made changes to what when and has options for easily updating a shared or public version of your code on github.com. You will need a supported web browser (current versions of Chrome, Firefox, Safari, Microsoft Edge, or Internet Explorer version 11 or above).

Windows

Git should be installed on your computer as part of your Bash install (described above).

macOS

Recent versions of macOS should have git already installed (or you had it installed together with Xcode). Check on the command line by running the command

git version

If this gives an output such as git version 2.41.0 then you have git.

For older macOS/Mac OS X 10.9 and higher, install Git for Mac by downloading and running the most recent “mavericks” installer from this list. Because this installer is not signed by the developer, you may have to right click (control click) on the .pkg file, click Open, and click Open on the pop up window. After installing Git, there will not be anything in your /Applications folder, as Git is a command line program.

Linux

If Git is not already available on your machine you can try to install it via your distro’s package manager. For Debian/Ubuntu run

sudo apt-get install git-all

and for Fedora run

sudo dnf install git-all

ChromeOS

You should have the bash shell and git already installed.

If git is missing, install it with

sudo apt-get install -y git

in the Terminal.

Text Editor

When you’re writing code, it’s nice to have a text editor that is optimized for writing code, with features like automatic color-coding of key words. The default text editor on macOS and Linux is usually set to Vim, which is not famous for being intuitive. if you accidentally find yourself stuck in it, try typing the escape key, followed by :q! (colon, lower-case ‘q’, exclamation mark), then hitting Return to return to the shell.

For this class we will use Visual Studio Code as the default editor. It is free, open source, available on Windows, macOS, Linux, and ChromeOS, powerful but also accessible for entry-level programmers.

Windows

Visual Studio Code is a good editor that is suitable for professional coding but also accessible to newcomers with is graphical user interface.1 To install it, download a suitable installer from code.visualstudio.com and double click on the file to run it. (For more details see Visual Studio Code on Windows.)

macOS

We recommend Visual Studio Code as a good editor that is suitable for professional coding but also accessible to newcomers with is graphical user interface.2

Install Visual Studio Code for macOS

To install Visual Studio Code,

  1. download a suitable installation zip file from code.visualstudio.com
  2. double click on the file to unpack it.
  3. Open your Applications directory from the Finder in the Go menu.
  4. Drag the unpacked Visual Studio Code application to your Applications directory.

(For more details see Visual Studio Code on macOS.)

Install the code command for VS Code

⚠️ If you are using Visual Studio Code then you need to install the code command so that we can launch Visual Studio Code from the command line:

  1. Launch Visual Studio Code.
  2. Open the Command Palette (Cmd+Shift+P).
  3. Type “shell command” to find Shell Command: Install code command in PATH command.

Restart the terminal for the new $PATH value to take effect.

You’ll be able to type code . in any folder to start editing files in that folder. (For more details see Launching from the command line.

Linux

We recommend Visual Studio Code as a good editor that is suitable for professional coding but also accessible to newcomers with is graphical user interface.3

Please follow the instructions on Visual Studio Code on Linux and ask an instructor for help if anything is unclear.

ChromeOS

Follow Chromebook: Install Visual Studio Code for all instruction.

Python

Python is a popular language for scientific computing, and great for general-purpose programming as well. Installing all of its scientific packages individually can be a bit difficult, so we recommend Anaconda, an all-in-one installer.

Regardless of how you choose to install it, please make sure you install Python version 3.x (e.g., 3.9 or 3.10 is fine).

We will teach Python using the Jupyter notebook, a programming environment that runs in a web browser. For this to work you will need a reasonably up-to-date browser. The current versions of the Chrome, Safari and Firefox browsers should all be supported (some older browsers, including Internet Explorer version 9 and below, are not).

Windows

The installation has two steps:

  1. Download and install the anaconda distribution.
  2. Modify a Git Bash startup file so that you can easily use the programs in the anaconda distribution from the Git Bash command line.
Windows anaconda installation

We first download and install the anaconda distribution:

  1. Open https://anaconda.com/download/#windows with your web browser.
  2. Download the Python 3 64-Bit installer for Windows.
  3. Install Python 3 using all of the defaults for installation except make sure to check Make Anaconda the default Python.
Modify Git Bash startup file for anaconda

The next step is a hack that ensures that you can call python and any other commands from the anaconda distribution (such as conda) from the Git Bash command line.

We are adding additional information to your bash shell startup file so that Anaconda will be found.

⚠️ These instructions assume that you installed Anaconda3 in the default location (C:\Users\YOUR-USERNAME\Anaconda3)— if you changed the location in the installation process then you will have to change the content of the MYCONDA variable below to use your custom location (ask an instructor for help if you are unsure how to do this).

The following commands must be typed exactly in Git Bash:

  1. open Git Bash (from the Start Menu)
  2. type
    cd
    echo $HOME
    

    (always hit RETURN after typing a command)

    You should see output such as /c/Users/YOUR-USERNAME (where “YOUR-USERNAME” stands for your user name, e.g., “alice”, “bob”, or “dvader”)

  3. type exactly (or copy & paste — you paste with right-mouse click in Git Bash):
    cat >> $HOME/.bash_profile << 'EOF'
    # PHY432 bash startup for local Anaconda
    MYCONDA="$HOME/Anaconda3"
    export PATH="$MYCONDA:$MYCONDA/Scripts:$MYCONDA/Library/bin:$PATH"
    unset MYCONDA
    EOF
    
  4. close Git Bash
  5. open a new Git Bash (this is important so that the changes take effect)
  6. type
    which conda
    

    Should print something like /c/Users/YOUR-USERNAME/Anaconda3/Scripts/conda.

⚠️ If the last step did not work then ask an instructor for help. You can also look at the detailed explanation in the PHY432 troubleshooting wiki, solution: pip or python are not found in git-bash.

macOS

  1. Open https://anaconda.com/download/#macos with your web browser.
  2. Download the Python 3 installer for MacOS.
  3. Install Python 3 using all of the defaults for installation.

Linux

  1. Open https://anaconda.com/download/#linux with your web browser.
  2. Download the Python 3 installer for Linux. (Most likely the 64-Bit (x86) Installer is correct for your laptop.)
  3. Install Python 3 using all of the defaults for installation. (⚠️ Installation requires using the shell. If you aren't comfortable doing the installation yourself stop here and request help.)
  4. Open a terminal window.
  5. Type
    bash ./Anaconda-
    and then press tab. The name of the file you just downloaded should appear.
  6. Press enter. You will follow the text-only prompts. When there is a colon at the bottom of the screen press the down arrow to move down through the text. Type yes and press enter to approve the license. Press enter to approve the default location for the files. Type yes and press enter to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python).

ChromeOS

Because ChromeOS only reserves a relatively small virtual disk for Linux we will not install the full Anaconda installation. Instead we install the small miniconda installer and then only install the packages that we need for the class. But you can easily install any other packages that you might need yourself.

Install miniconda

We generally follow the original installation instructions for Linux but we will manually download the installer because we cannot easily transfer a downloaded file from Chrome’s download folder to the Linux system.

  1. Open the Terminal.
  2. Create a download directory in your home directory
    cd
    mkdir -p Downloads
    
  3. Change to the Download directory
    cd Downloads
    
  4. In your Chrome web browser: Obtain the download link for latest Miniconda3 installer:
    1. Go to the miniconda Linux installers page.
    2. Find the latest Python version (e.g., 3.10).
    3. Look for the name Miniconda3 Linux 64-bit.
    4. Copy the link (E.g. in Chrome, hover over the Miniconda3 Linux 64-bit entry and from the context menu choose Copy Link Address.)
  5. In Terminal: type wget and then paste the URL: it should look like the following (but your link may be different)
    wget https://repo.anaconda.com/miniconda/Miniconda3-py310_22.11.1-1-Linux-x86_64.sh
    

    Execute the wget command. You should see download progress.

    (wget downloads from the commandline instead of using the browser.)

  6. You now have the installer file Miniconda3-py310_22.11.1-1-Linux-x86_64.sh in your Downloads directory (your name may be different but always start with “Miniconda3-“). Run the installer with
    bash Miniconda3-*-Linux-x86_64.sh
    
    • Press Enter to review the license agreement. Then press and hold Enter to scroll.
    • Enter “yes” to agree to the license agreement.
    • Use Enter to accept the default install location. (It will show something like /home/YOUR_USERNAME/miniconda3.)
    • The installer prompts you to choose whether to initialize Anaconda Distribution by running conda init. Enter “yes”.
    • The installer finishes.
  7. Close and reopen Terminal.

    (You need to open a new Terminal so that the changes can take effect that the installer made so that all conda packages are found.)

You can delete the miniconda installer unless you want to later re-install.

Install Python packages for the class

We need a number of packages. In the following we install all of them at once but if you have issues with the process timing out then execute each installation separately.

In the Terminal, run

conda install numpy pytest matplotlib scipy ipython jupyter ipympl pytest-timeout

Testing

Once you have installed everything, go through the individual steps below and executed every command. Compare what happens in your case to what is described.

⚠️ If you don’t get equivalent output, ask an instructor for clarification or help.

Bash shell

Open a terminal (macOS, Linux) or open Git Bash (under All Programs/Git/Git Bash) in Windows.

Type

echo $SHELL

Should show /bin/bash or /usr/bin/bash (or similar).

We use “shell” and “terminal” (and “console”) pretty much interchangeably.

Git

In the shell, type

git --version

which should show something like git version 2.7.0.

editor (Visual Studio Code)

First time

Open Visual Studio Code using your GUI

  • Windows: from the start menu
  • macOS: from the Application folder
  • Linux: varies (but you might be able to skip to “From the shell”)

A window should open showing the Visual Studio Code logo and get started screen, similar to

Visual Studio Code get started screenshot

Then exit the editor again (Exit from the menu or close the window).

From the shell

In the shell, type

code

It should open the editor. Exit the editor.

Python

python interpreter

In the shell, type

python -c 'import sys; print(sys.version)'

which should give something similar to Python 3.8.5 (default, Sep 4 2018, 07:30:14) (and more stuff). Important: You should have Python 3, i.e., a version like 3.8.x or 3.10.x

Also try

which conda 
which python

which should give something similar to /homes/USERNAME/anaconda3/bin/conda, /homes/USERNAME/anaconda3/bin/python

Jupyter notebook

  1. In the shell, type
    jupyter notebook
    This should open a browser window at http://localhost:8888.
  2. Open the New menu on the right hand side.
  3. Under Notebooks select Python or Python [conda root] (if it is shown)
  4. In the new window ("Untitled"), type
    print("Hello World!")
    and press shift and return keys simultaneously to evaluate the cell. It should print "Hello World!".
  5. Close the browser tab with menu File: Close and Halt.

If you have problems, ask an instructor.

Common problems

  • On Windows, the python (or conda or pip) commands are not found. Follow the steps under solution: pip or python are not found in git-bash
  • On macOS, if you get the error OSError: [Errno 49] Can’t assign requested address you might need to use jupyter notebook --ip=127.0.0.1
  • Wrong conda is used. Check which conda in the terminal: it should show a path in your home directory (e.g., for user “physics”: Windows: /c/Users/Physics/Anaconda3/conda, macOS: /Users/physics/Anaconda3/conda, Linux: /home/physics/Anaconda3/conda). Try exiting the terminal and open a new terminal (or Git Bash) and try again. Changes to PATH only take effect when a new shell is opened.

See also trouble shooting problems during the installation

Credits

The instructions were originally taken from Software Carpentry (in particular David Dotson’s 2016 workshop at ASU and the SWC Workshop Template) and adapted for the PHY 432 class.

Instructions for Chromebooks come from Learning with VS Code on Chromebooks (December 3, 2020) by Alessandro Segala @ItalyPaleAle.


Footnotes

  1. Others editors that you can use in Windows are Notepad++ or Sublime Text. Be aware that you must add its installation directory to your system path. Please ask your instructor to help you do this. 

  2. Alternative editors for macOS: If you don’t want to use VS Code, you can always use nano, which is a basic editor. It should be pre-installed. Others editors that you can use are Text Wrangler or Sublime Text

  3. Alternative editors for Linux: nano is a basic editor. It should be pre-installed. Others editors that you can use are Gedit, Kate or Sublime Text. More old-school (but very powerful) are Emacs and Vim (both of which come with a steep learning curve)