Repository navigation
Getting started
This page shows how to install gpython and how to do a first session.
- Python 3.13 or newer.
- A terminal. Ghostty, Kitty, WezTerm and iTerm2 give the best results (see Troubleshooting).
-
uvis optional. gpython uses it when it is installed.
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
|
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.
gpython # an empty notebook without a name
gpython script.py # open a file
gpython notebooks/ # open the file explorer in a folderAll options are on the Command line page.
| 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.
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.
| 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 |
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 |
| 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.
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 |
#38bdf8
|
A blue block on the current line of the selected cell | Blue | |
| NORMAL |
#f5c451
|
A yellow block | Yellow | |
| INSERT |
#a3e635
|
A green block | Green | |
| VISUAL |
#c084fc
|
A purple block. The selection is highlighted | Purple | |
| REPLACE |
#f87171
|
A red block | Red | |
| DEBUG |
#ef4444
|
— | 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.
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.
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.
- Start
gpython. The first cell is open. - Press
iand typex = 2. - Press
shift+enter. gpython runs the cell and goes to the next cell. - Type
x * 21and pressshift+enter. The result shows below the cell. - Press
escapetwo times to go to cell mode. - Press
kto select the cell above. Pressbto add a cell below. - Press
ctrl+s. gpython asks for a file name, then saves the notebook as a.pyfile. - Press
f1to see all keys. Pressctrl+qto quit.
If your terminal does not send shift+enter, use alt+enter.
- Running cells tells you which cells run, and when.
-
Keys and Commands list all keys and
:commands. - Configuration lists all settings.
Use the notebook
- Getting started
- Command line
- Running cells
- Keys
- Commands
- Vim
- Markdown cells
- Variables and the debugger
- Images
Set up the workspace
Help and project