JupyterLab Environment

What is a Notebook?

Notebooks are documents that can contain code (like python) and rich text elements (paragraphs, equations, figures, links). You can edit and re-run cells, in place, inside a notebook. Notebooks are:

  • Executable documents that can be run to perform data analysis

  • Human-readable documents that can contain the analysis description and results

Using a Notebook

In the launcher window, by default, there is a Python 3 notebook icon that you can use to launch a Python 3 notebook. There is also an R notebook if you are logged into the R server.

Python notebook and console options in JupyterLab launcher.

Switching Between Code, Markdown, and Raw

To switch between inputting executable code, and rich text elements in your notebook cell:

  1. Find the Select the cell type dropdown menu at the top of the notebook window (the default selection is Code):

    Notebook select the cell type dropdown menu.
  2. From the dropdown menu, select the cell type you would like to use:

    Notebook select the cell type dropdown menu opened showing Code, Markdown, and Raw cell type options.

Command and Edit Modes

Jupyter notebooks have two modes of interaction: command mode and edit mode.

In command mode, you can:

  • Navigate between cells

  • Add and delete cells

  • Change the cell type

  • Rearrange cells

In edit mode, you can:

  • Edit the contents of a cell

To enter command mode, you can either press the escape key (esc) or click outside a cell. The mode you are in is shown in the bottom-right corner of your notebook:

Jupyter notebook mode displayed in bottom-right corner of the notebook.

What is a Console?

Consoles allow you to run code in a kernel.

In consoles, you can:

  • Display rich text elements from code output

  • Edit and re-run code in a new cell

In consoles, you can’t:

  • Input rich text elements separate from a code output

  • Edit and re-run cells in place

Using a Console

In the launcher window, by default, there is a Python 3 console icon that you can use to launch a Python 3 console. There is also an R console if you are logged into the R server.

Python notebook and console options in JupyterLab launcher.

Clearing the Console

To clear the console without restarting the kernel, right-click inside the console and select Clear Console Cells.

Console right-click menu that includes clear console cells option.

Browsing Your Input History

Browse your cell input history using your up and down keyboard arrows inside the console input cell. You can edit and re-run previously run code with this method more quickly than re-typing.