Skip to content

REPL

The REPL runs a line, a selection or a block of code in a Jupyter kernel and shows the output right under it. It works in ordinary source files, so there is no notebook to manage.

Install a kernel

Tyrn needs a kernel for each language you want to run. These are supported:

Language Kernel
Python ipykernel
TypeScript and JavaScript Deno
R Ark or Xeus-R
Julia The Julia Jupyter kernel
Scala Almond

Python

Set up a kernel for your current Python:

Terminal window
pip install ipykernel
python -m ipykernel install --user

For a virtual environment or conda environment, activate it first, then install ipykernel and register it with a name:

Terminal window
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

TypeScript with Deno

Install Deno, then:

Terminal window
deno jupyter --install

Other languages

Install the kernel following its own instructions, for example Ark for R (ark --install) or Almond for Scala. Language support for R and Julia comes from language extensions.

If you add a kernel while Tyrn is open, run repl: refresh kernelspecs from the command palette.

Run code

Open a file and press ctrl-shift-enter to run the selection, or the current line or block if nothing is selected. The result appears below. ctrl-alt-enter runs without moving to the next block.

The REPL Menu in the editor toolbar has Run Selection (or Run Line), Interrupt, Clear Outputs, Restart Kernel, Shut Down Kernel and View Sessions. The same commands are in the command palette:

  • repl: clear outputs and repl: clear current output
  • repl: interrupt, repl: restart and repl: shutdown for the running kernel
  • repl: sessions lists running kernels

Cells in a script

Separate cells with # %% in Python, or // %% in TypeScript. Each run executes the code between two markers.

# %% Load data
import numpy as np
data = np.arange(10)
# %% Plot
import matplotlib.pyplot as plt
plt.plot(data)

Changing kernels

Tyrn finds kernels for you and lists them in the kernel picker (Select Kernel in the editor toolbar):

  • Recommended: the Python environment that matches your active toolchain.
  • Python Environments: virtual environments such as venv, Poetry, Pipenv, conda and uv.
  • Jupyter Kernels: installed kernelspecs.
  • Remote Servers: connected remote Jupyter servers.

An environment without ipykernel is listed with “ipykernel not installed”. Selecting it installs ipykernel into that environment.

When you run code with no choice made, Tyrn picks a kernel in this order:

  1. A Python environment that matches your active toolchain and has ipykernel.
  2. The first Python environment with ipykernel.
  3. A Jupyter kernel that matches the language of the code.

You can override the choice with Select Kernel in the editor toolbar. To set a default per language, use jupyter.kernel_selections:

settings.json
{
"jupyter": {
"kernel_selections": {
"python": "conda-env",
"typescript": "deno",
"javascript": "deno",
"r": "ark"
}
}
}

The value is the kernelspec name. If jupyter is installed, jupyter kernelspec list shows the names.

Input prompts

When code asks for input, such as Python’s input(), a prompt appears under the output. Type your answer and press enter. Password prompts are masked.

Settings

settings.json
{
"jupyter": { "enabled": true },
"repl": {
"max_columns": 128,
"max_lines": 32,
"output_max_height_lines": 0,
"output_max_width_columns": 0
}
}

Set jupyter.enabled to false to turn the REPL off. output_max_height_lines and output_max_width_columns limit output size, and 0 means no limit.