Thebe Lab turns your static HTML pages into interactive ones, powered by a kernel. It is an experiment attempting to rebuild Thebe with javascript APIs provided by JupyterLab. This should make Thebe a smaller, more sustainable project.

For example, see the following code cell:

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.scatter(*np.random.randn(2, 100), c=np.random.randn(100))
ax.set(title="Wow, an interactive plot!")

It is static for now. You can activate Thebelab by pressing the button below. This will ask for a Python kernel, and turn the code cell into an interactive one with outputs!

Try clicking the button. The cell will be come active!

You can press “run” in order to run the contents of the cell and display the result (be patient, it will take a few moments for Binder to start the kernel).

How ThebeLab works

Starting ThebeLab involves the following steps:

  1. Loading the thebelab javascript, typically from a CDN

  2. Fetching the ThebeLab configuration from the page header

  3. Bootstrapping ThebeLab: * Re rendering the code cells to make them live cells. Optionally, the rendering can handle cells that contain a mixture of inputs and ouputs distinguished by prompts (see the stripPrompts option); * (optional) Requesting a notebook server from Binder; * (optional) Requesting a Jupyter kernel from the Jupyter server.

  4. Bootstrap Thebelab by calling thebelab.bootstrap().

    If bootstrap: true is in the Thebelab configuration (see below), this will be triggered automatically upon page load.

Getting Started

To get started, we check out A minimal example.

More examples

For more examples showing how to configure, use, and activate Thebelab, see the list below. We recommend browsing the raw HTML of each one in order to see how Thebelab is used.


thebelab was originally developed as a part of OpenDreamKit - Horizon 2020 European Research Infrastructure project (676541).