Skip to article frontmatterSkip to article content

Running Jupyter Notebooks


Jupyter Notebooks allow users to display:

Jupyter Notebooks provide an ideal file format for teaching/learning coding concepts and prototyping algorithms.



Notebook Cell Types

Markdown Cells

Markdown cells contain documentation in Markdown, MyST Markdown, HTML, and/or LaTeX. They are often used to display text, images, hyperlinks, formulas, tables, pseudocode, plots, figures, etc.

Markdown Edit Mode

To enter edit mode in a markdown cell, double-click the cell.

Double-click on a markdown cell to enter edit mode

Double-click on a markdown cell to enter edit mode

Markdown Display Mode

To render a markdown cell, select it then:

or

A run markdown cell

A run markdown cell

Code Cells

Code cells contain editable and runnable Python code. You can run them sequentially or in any order, once or any number of times.

Selecting and running a code cell

Selecting and running a code cell


How to Run Jupyter Notebooks

Selecting Cells

Users may select cells individually or in a batch, and then run the selected cells.

Select an Individual Cell

A selected cell displays a blue vertical line on the left edge.

A selected cell displays a blue vertical line on the left edge.

Select Multiple Cells

  1. Select a cell by clicking to the left of the text box
    • Clicking inside the cell will select it but it will place you in text edit mode and you will not be able to select additonal cells.
  2. Select additional cells using:
    • shift + j or shift + Down-Arrow to select additional cells below
    • shift + k or shift + Up-Arrow to select additional cells above
    • shift + mouse click to select batches of cells
  3. Perform batch operations on selected cells with button or with Ctrl + Enter or Cmd + Enter (Mac).
Selected cells will be surrounded by a blue background

Selected cells will be surrounded by a blue background

Hide Code Cells

You may occasionally wish to hide code cells to reduce clutter.

Collapse an Individual Cell

You can hide an individual code cell by clicking the blue vertical line to the left of the code cell.

You can hide an individual code cell by clicking the blue vertical line to the left of the code cell.

Collapse Selected Cells or All Cells in a Notebook

Hide Sections of Code Cells beneath a Markdown Cell

Hide entire sections of code cells beneath a markdown cell by clicking the vertical blue bar to the left of the markdown cell.

Hide entire sections of code cells beneath a markdown cell by clicking the vertical blue bar to the left of the markdown cell.


Running Code Cells

Code cells may be executed in any order. A cell execution counter to the left of each code cell indicates the order in which the cells were run.

The cell execution counter indicates the order in which code cells have run.

The cell execution counter indicates the order in which code cells have run.

Run a Single Code Cell

  1. Select the cell you wish to run.
  2. Do one of the following:
    • Click the button at the top of the notebook.
    • Ctrl + Enter or Cmd + Enter (Mac) to run a cell.
    • Shift + Enter to run a cell and select the cell below
    • Alt + Enter to run a cell and insert an empty cell below

Run Multiple Code Cells

Run a batch of selected cells

  1. Select a group of cells.
  2. Do one of the following:
    • Click the button at the top of the notebook.
    • Ctrl + Enter to run a cell.
    • Shift + Enter to run a cell and select the cell below
    • Alt + Enter to run a cell and insert an empty cell below

Run Every Cell Above or Below a Code Cell

Select a cell, then:

Run an Entire Notebook

If you wish to run every code cell in a notebook, you can do one of the following:


Rerunning a Notebook

We recommend restarting the notebook kernel before rerunning it since any initialized variables and data structures from a previous run persist in memory along with their values, which can lead to unintended results.

To restart the kernel so you can begin a fresh notebook run use one of the following options:


Clearing Cell Output Before Closing

For large notebooks with a lot of plots and images, we recommend clearing all code cell output before closing or saving a notebook. Leaving the output in place can increase the file size of the notebook, which can cause slower notebook loading times (especially if you have a slow internet connection).