Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 39 ยท JupyterLab and Extensions

JupyterLab Extensions and Customization

Install and manage JupyterLab extensions with pip, learn prebuilt versus source extensions, useful ones such as the LSP and Git tools, and how an extension is structured.

JupyterLab is built from plugins: the file browser, notebook editor and command palette are all extensions that ship with it. You can add more to get a code formatter, Git support, spell checking, a variable inspector or a new theme. This lesson explains how extensions are installed and managed today, what the common ones do, and what is inside a minimal extension.

JupyterLab is not available on this site, so installation commands are read-only and described honestly. The runnable cells model the discovery and compatibility checks with plain Python.

Two kinds of extension

  • Prebuilt extensions are Python packages that carry their own compiled JavaScript. Installing the package with pip or conda is enough. No Node.js, no rebuild. This is the modern way (JupyterLab 3 and later) and what you should prefer.
  • Source extensions were the older style: they needed Node.js and a jupyter lab build step to bundle JavaScript into the app. You will meet them only in older guides or for in-development extensions.

Many extensions also have a server part (a Python package that adds web endpoints), for example the Git extension or the language server. The pip package carries both parts, and the installer enables them automatically.

Installing and managing

Terminal
pip install jupyterlab-git            # install into the active environment
jupyter labextension list             # show every extension and whether it is enabled
jupyter labextension disable @jupyterlab/git
jupyter labextension enable  @jupyterlab/git
pip uninstall jupyterlab-git          # remove it

After installing, reload the browser tab. If an extension also has a server component, restart the Jupyter server so it loads. Installed extensions live in the environment, so they follow your project environment; list them in your requirements file like any other package.

JupyterLab also has an Extension Manager in the left sidebar. It can search PyPI and install from the interface, but installing through the command line (and recording the result) keeps the project reproducible, so many teams disable the manager for shared servers.

Extensions worth knowing

Package What it adds
jupyterlab-lsp and python-lsp-server completion, hover docs, diagnostics, rename
jupyterlab-git a Git panel: stage, commit, diff, branches
jupyterlab-code-formatter format code cells with Black, isort or Ruff
jupyterlab-spellchecker spell check in Markdown cells
jupyterlab-execute-time shows how long each cell took
jupyter-resource-usage memory and CPU in the status bar
jupyterlab-variableinspector table of variables in the kernel
jupyterlab-drawio diagrams inside the workspace
jupyterlab-night or theme packages colors and icons

Install a few that solve a real annoyance, not everything: each one adds startup time and an interface surface to learn.

Themes and the Settings Editor

Themes are extensions too. After installing one, pick it under Settings, Theme. Fine-grained behavior is controlled in the Settings Editor or in JSON files under your user settings folder (for example overrides.json in the application settings directory), which can set defaults for a whole team.

JSON
{
  "@jupyterlab/apputils-extension:themes": {
    "theme": "JupyterLab Dark"
  },
  "@jupyterlab/notebook-extension:tracker": {
    "codeCellConfig": { "lineNumbers": true }
  }
}

What is inside an extension

An extension is a JavaScript (TypeScript) package that exports one or more plugins. Each plugin has an id, a list of requires (services it depends on, such as the command registry), and an activate function that registers commands, menu items or widgets.

TypeScript
import { JupyterFrontEndPlugin, JupyterFrontEnd } from '@jupyterlab/application';

const plugin: JupyterFrontEndPlugin<void> = {
  id: 'hello-extension:plugin',
  autoStart: true,
  activate: (app: JupyterFrontEnd) => {
    app.commands.addCommand('hello:say', {
      label: 'Say Hello',
      execute: () => console.log('Hello from an extension')
    });
  }
};
export default plugin;

After activate runs, "Say Hello" appears in the command palette. A new extension is normally created from the official copier template, which sets up the Python packaging, the TypeScript build and the tests.

A plugin registry in miniature

The pattern is the same as a small plugin system in any language: a registry, plugins with ids and dependencies, and an activation order that respects the dependencies. The runnable cell builds that idea in Python. It is a stand-in; JupyterLab itself uses TypeScript.

Python Plugins with dependencies activate in order

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

broken is skipped because its dependency is missing, but the other plugins load. In JupyterLab a failing extension is reported in the browser console and the rest of the app keeps working.

Version compatibility

Extensions are built against a major version of JupyterLab. A package that targets JupyterLab 4 will not load in 3. The Python package declares this in its metadata, so pip usually refuses an impossible combination. If an extension fails to show up:

  1. Run jupyter labextension list and read the message next to it (it often says "enabled, OK" or "not compatible").
  2. Check pip list for the JupyterLab and extension versions.
  3. Restart the server and hard-reload the browser.
Python Check an extension against the Lab version

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main advantage of a prebuilt extension?

    Prebuilt extensions ship compiled JavaScript inside a pip or conda package.
  2. 2. Which command lists installed extensions and their status?

    jupyter labextension list shows each extension and whether it is enabled and compatible.
  3. 3. What does a plugin's activate function typically do?

    Activation is where the plugin attaches its features to the running app.
  4. 4. An extension built for JupyterLab 3 does not appear in JupyterLab 4. What is the likely cause?

    Extensions target a major version of the application and often need a newer release.

Summary

  • Prefer prebuilt extensions: pip install, reload, done.
  • Manage them with jupyter labextension list, enable and disable, and record them in your requirements.
  • Install only a few useful extensions: LSP, Git, a formatter and resource usage are common choices.
  • An extension is a set of plugins with ids, dependencies and an activate function; version compatibility is the usual source of problems.

Next: Version Control for Notebooks