All topics
Data · Learning hub

JupyterLab notes for developers

Master JupyterLab with a curated set of 2 developer notes — core concepts, patterns, and interview prep. Maintained by the DevRecall team.

Save this stack to your DevRecallMore Data notes
JupyterLab

Interface, Notebooks & Kernels

JupyterLab: Interface, Notebooks & Kernels JupyterLab is the next-generation web-based IDE for Jupyter. It replaces the classic Jupyter Notebook UI with a flexi

JupyterLab: Interface, Notebooks & Kernels

JupyterLab is the next-generation web-based IDE for Jupyter. It replaces the classic Jupyter Notebook UI with a flexible, tabbed workspace supporting notebooks, terminals, text editors, and file browsers side by side.

Installation & Launch

pip install jupyterlab
jupyter lab                        # launch in browser
jupyter lab --port=8889            # custom port
jupyter lab --no-browser           # headless (get URL from output)
jupyter lab --ip=0.0.0.0           # bind to all interfaces (remote server)

# Install specific version
pip install jupyterlab==4.0.0

# With conda
conda install -c conda-forge jupyterlab

Notebooks

A notebook is a JSON document (.ipynb) containing cells — code, Markdown, or raw. Each notebook connects to a kernel (Python, R, Julia, etc.) that executes code cells.

# Cell types
# Code cell: executes code in the kernel language
import numpy as np
arr = np.arange(10)
arr ** 2

# Markdown cell: renders Markdown/LaTeX
# Use ## headings, **bold**, *italic*, $E = mc^2$

# Raw cell: not executed, not rendered — used for nbconvert directives
Keyboard shortcuts (command mode — press Esc):
  A          — insert cell Above
  B          — insert cell Below
  D D        — delete cell
  M          — change to Markdown
  Y          — change to Code
  Shift+Enter — run cell, move to next
  Ctrl+Enter  — run cell, stay
  Alt+Enter   — run cell, insert below
  Z           — undo cell deletion
  0 0         — restart kernel
  1-6         — change heading level (Markdown)

Edit mode (press Enter):
  Tab            — autocomplete
  Shift+Tab      — inspect signature/docstring
  Ctrl+/         — toggle comment
  Ctrl+Shift+-   — split cell at cursor

Kernels

# List available kernels
jupyter kernelspec list

# Install a new kernel (e.g., for a venv)
pip install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

# Remove kernel
jupyter kernelspec remove myenv

# Other language kernels
pip install IRkernel       # R
# julia: run Pkg.add("IJulia") in Julia REPL

JupyterLab Interface

  • Left sidebar: file browser, running terminals/kernels, extension manager, table of contents.

  • Main area: tabs for notebooks, editors, terminals, CSV viewers. Drag tabs to split view.

  • Command palette (Ctrl+Shift+C): search all commands — faster than menus.

  • Context menus: right-click cells or file browser entries for common actions.

  • Settings editor (Settings → Advanced Settings): customize keybindings, themes, autosave.

  • Single-document mode (View → Simple Interface): hides sidebar for distraction-free work.

JupyterLab

Extensions, Magic Commands & Best Practices

JupyterLab: Extensions, Magic Commands & Best Practices Magic Commands # Line magics (single %) %timeit arr.sum() # benchmark a single expression %time result =

JupyterLab: Extensions, Magic Commands & Best Practices

Magic Commands

# Line magics (single %)
%timeit arr.sum()               # benchmark a single expression
%time result = slow_function()  # time a single execution
%run script.py                  # execute a .py file
%load script.py                 # load file contents into cell
%who                            # list all variables
%whos                           # list variables with type/value
%reset                          # clear all variables
%matplotlib inline              # render plots inline
%matplotlib widget              # interactive plots (ipympl)
%env MY_VAR=value               # set environment variable
%pwd                            # print working directory
%ls                             # list files
%cd /path/to/dir                # change directory
%history                        # show cell history

# Cell magics (%% — apply to entire cell)
%%timeit
result = [x**2 for x in range(10000)]

%%bash
echo "Hello from bash"
ls -la

%%writefile myfile.py
def hello():
    print("Hello")

%%capture output
import subprocess
result = subprocess.run(['ls'], capture_output=True)

# IPython display utilities
from IPython.display import display, HTML, Image, Markdown, JSON
display(HTML('<b>Bold HTML</b>'))
display(Markdown('# Markdown heading'))
display(Image('plot.png'))

Popular Extensions

# Extensions install via pip (JupyterLab 3+)
pip install jupyterlab-git           # Git integration in sidebar
pip install jupyterlab-lsp           # Language Server Protocol (autocomplete, hover)
pip install python-lsp-server        # Python LSP backend for jupyterlab-lsp
pip install jupyterlab_code_formatter # Black/isort formatting
pip install black isort              # formatters for above
pip install ipympl                   # interactive matplotlib (%matplotlib widget)
pip install jupyterlab-drawio        # Diagram editor
pip install elyra                    # AI/ML pipeline builder
pip install nbdime                   # Notebook diffing/merging

# Check installed extensions
jupyter labextension list

nbconvert — Export Notebooks

# Export to other formats
jupyter nbconvert notebook.ipynb --to html
jupyter nbconvert notebook.ipynb --to pdf
jupyter nbconvert notebook.ipynb --to script   # .py file
jupyter nbconvert notebook.ipynb --to markdown
jupyter nbconvert notebook.ipynb --to slides   # reveal.js

# Execute and export (re-runs all cells first)
jupyter nbconvert notebook.ipynb --to html --execute
jupyter nbconvert notebook.ipynb --execute --inplace  # save results back

# Papermill: parameterized execution
pip install papermill
papermill notebook.ipynb output.ipynb -p alpha 0.1 -p n_epochs 10

Best Practices

  • Restart kernel and run all cells (Kernel → Restart Kernel and Run All) before sharing — catches hidden state bugs.

  • Keep cells short and focused. Long cells with many side effects are hard to re-run selectively.

  • Use %store variable_name to persist variables across sessions (stored in IPython profile).

  • Name notebooks descriptively with dates: 2024-03-15-eda-user-churn.ipynb.

  • Use nbstripout (pre-commit hook) to strip output before git commits — keeps diffs clean.

  • For production code, refactor notebook logic into .py modules; import and call from notebook.

  • Use papermill for automated notebook execution with parameter injection (CI/CD reports).

  • JupyterHub: multi-user server for teams — each user gets an isolated server session.

Keep your JupyterLab knowledge sharp.

Save this stack to your personal DevRecall — add your own notes, track what you're learning, and share what you know with the community.

Get started — free forever