Skip to content

Getting started

igaurab edited this page Nov 18, 2026 · 2 revisions

This page shows how to install gpython and how to do a first session.

Requirements

  • Python 3.13 or newer.
  • A terminal. Ghostty, Kitty, WezTerm and iTerm2 give the best results (see Troubleshooting).
  • uv is optional. gpython uses it when it is installed.

What your terminal can show

gpython works in each terminal. Some functions need a terminal that supports them.

Function Terminals that support it In other terminals
Images and Matplotlib figures in the notebook Kitty, Ghostty, Rex, WezTerm, Konsole (kitty graphics protocol), and terminals with Sixel A coarse picture from colored cells, or View and Download buttons. See Images
Pictures and animated GIFs in markdown cells The same terminals A coarse picture of the first frame. See Markdown cells
Large markdown headings (off by default) Kitty, Ghostty. Set experimental.true_markdown = true in the config file Headings show as text
shift+enter and ctrl+enter Ghostty, Kitty, WezTerm, iTerm2 Use alt+enter

Install

The package name on PyPI is gpynb. It installs two commands: gpython and the short name gpy.

Task Command
Install with uv uv tool install gpynb
Update with uv uv tool upgrade gpynb
Run one time, without installation uvx --from gpynb gpython
Install with pipx pipx install gpynb

To run gpython from a source checkout, see Development.

Start gpython

gpython              # an empty notebook without a name
gpython script.py    # open a file
gpython notebooks/   # open the file explorer in a folder

All options are on the Command line page.

The screen

Part What it shows
Header, top The file name and the kernel label (● Python 3.12.4 · .venv ▾)
Tab line One entry for each tab. It shows only when there are two or more tabs, or a hidden buffer
Cells Each cell has a header (✓ c3 [4] defines x · uses y), its code and its output
Bottom bar The mode badge on the left. Clock, host, cpu, ram and gpu on the right

The kernel is the Python process that runs your cells. Each notebook has its own kernel.

Modes

A mode tells gpython what your keys do. The same key can do different things in different modes. For example, j types the letter j in insert mode, moves the cursor down in normal mode, and selects the next cell in cell mode.

The three main modes

Mode Where you are What the keys do
CELL On a cell, not in its text The keys work on cells: move, add, delete, copy, run
NORMAL In the editor of a cell The keys are vim commands: move the cursor, delete, copy, change text
INSERT In the editor of a cell The keys type text

More modes

You get to these modes from NORMAL mode or when a cell is paused.

Mode How you get there What the keys do
VISUAL v, V or ctrl+v in NORMAL mode Movement keys select text. Then a command works on the selection
REPLACE R in NORMAL mode The keys type over the text that is there
DEBUG A cell stops at breakpoint(), or you press r d The keys control the debugger. See Variables and the debugger

How to change the mode

You are in Key You go to
INSERT escape NORMAL
VISUAL or REPLACE escape NORMAL
NORMAL escape CELL
NORMAL i, a, o and the other vim insert keys INSERT
CELL enter or i NORMAL, in the editor of the selected cell
CELL o / O INSERT, in a new cell below / above

Thus escape escape always brings you from INSERT to CELL mode, and enter then i brings you back to INSERT mode.

The mouse also changes the mode:

  • A click on a cell header selects that cell.
  • In cell mode, a click on a cell only selects it. The mode stays CELL.
  • While you edit, a click in an editor puts the cursor there.

A markdown cell that shows its text, and a cell with hidden code, have no open editor. gpython always selects them as a cell. Press enter to open the editor.

How to see the mode

Three things show the mode. They use the same color, so one look is sufficient.

Mode Color Badge in the bottom bar Cursor Bar at the left of the cell
CELL Sky blue #38bdf8 CELL A blue block on the current line of the selected cell Blue
NORMAL Yellow #f5c451 NORMAL A yellow block Yellow
INSERT Green #a3e635 INSERT A green block Green
VISUAL Purple #c084fc VISUAL A purple block. The selection is highlighted Purple
REPLACE Light red #f87171 REPLACE A red block Red
DEBUG Red #ef4444 DEBUG — Red on the paused cell. The paused line is lit

One more bar color is not a mode: a salmon bar (#e8846b) shows a stale cell. A stale cell is out of date and must run again.

How to see the state of a cell

Each cell header starts with a mark.

Mark Color State of the cell
○ Dim Did not run
◌ Yellow Stale
… Cyan Waits to run
● Cyan Runs now
✓ Green Ran correctly
✗ Red Ended with an error
⊘ Red Did not run, because a cell that it uses failed

If you want a thin cursor in insert mode, type :set cursor=bar or :set cursor=underline. The cursor keeps the color of the mode.

While the file explorer has the keyboard, the badge shows NORMAL, as in vim.

Without vim

If you do not use vim, start gpython with --no-vim or type :set novim. Then the editor has no NORMAL mode. One escape goes from the editor to CELL mode. :set vim turns the vim keys on again. gpython saves the :set choice.

A first session

  1. Start gpython. The first cell is open.
  2. Press i and type x = 2.
  3. Press shift+enter. gpython runs the cell and goes to the next cell.
  4. Type x * 21 and press shift+enter. The result shows below the cell.
  5. Press escape two times to go to cell mode.
  6. Press k to select the cell above. Press b to add a cell below.
  7. Press ctrl+s. gpython asks for a file name, then saves the notebook as a .py file.
  8. Press f1 to see all keys. Press ctrl+q to quit.

If your terminal does not send shift+enter, use alt+enter.

Where to go next

Clone this wiki locally