Working effectively in JupyterLab

Jupyter · Practical · 10 min

JupyterLab is a full workspace; using it as a single-notebook viewer leaves most of its productivity on the table.

JupyterLab arranges documents and tools in tabs you can drag to split the main area, for example a notebook beside the CSV it reads, or two views of the same notebook.

Features worth knowing:

  • File browser (left sidebar): open notebooks, CSV files (shown as a grid), images, Markdown with live preview, and text editors with syntax highlighting.
  • Consoles: right-click a notebook and choose "New Console for Notebook" to get a scratch area attached to the same kernel, ideal for quick checks without cluttering the notebook.
  • Terminals: a full shell in the browser, useful on remote servers.
  • Running panel: lists open kernels and terminals so you can shut down forgotten ones holding memory.
  • Table of contents: built from Markdown headings, for navigating long notebooks.
  • Debugger: enable the bug icon on a notebook to set breakpoints by clicking line numbers, then inspect variables and the call stack (requires an ipykernel with debugger support, which current versions have).
  • Contextual help (Ctrl+I) shows documentation for the object under the cursor.
  • Collapsible cells and outputs, and "Render side-by-side" for long outputs.
  • Real-time collaboration via the jupyter-collaboration extension.

Extensions add features such as Git integration (jupyterlab-git), language servers for completion and linting (jupyterlab-lsp) and formatters. In JupyterLab 4 most are installed with pip, with no build step; jupyter labextension list shows what is installed.

Example

jupyter lab --version                 # 4.6.x
jupyter labextension list             # installed front-end extensions

# Common extensions are plain pip packages in JupyterLab 4
pip install jupyterlab-git            # Git panel
pip install jupyterlab-lsp python-lsp-server   # completion, hover, linting
pip install jupyter-collaboration     # real-time collaboration

# Settings live in JSON and can be versioned per user
ls ~/.jupyter/lab/user-settings/@jupyterlab/

Remember

  • Split the main area to work on several documents side by side
  • Attach a console to a notebook's kernel for scratch work
  • Use the Running panel, debugger and table of contents; add extensions with pip

Watch out for

  • Leaving many kernels running in the background, each holding data in memory.

Check yourself

  1. You want to try quick expressions against a notebook's variables without adding cells to it. What do you use?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: jupyterlab.readthedocs.io/en/stable/user/interface.html