nberror
Collects Jupyter cell errors together with the context a traceback leaves out — DataFrame shapes, which names are missing from the namespace, and what you ran before — into one text you can hand to an AI agent, or just read yourself.
A traceback tells you where execution stopped. It rarely tells you why: that
your DataFrame has 17 columns and duration is one of them while you asked for
durations, or that the cell defining the variable was never run in this kernel.
pip install nberror
%load_ext nberror
That's it. Run cells as usual. When one fails you see the normal traceback plus:
[viga logitud - küsi AI-agendilt "viga" või jooksuta: nberror]
Then, from the terminal:
nberror
What the report contains
- **Erind:** `KeyError: "['durations'] not found in axis"`
- **Lahter:** In[5], kestus 2.02s
## Lahtri kood the whole cell, not just the failing line
## Traceback
## Muutujad, mis lahtris esinevad ja on olemas
- `df`: DataFrame kuju=(45211, 17), 17 veergu: age, job, ..., duration ...
## Nimed, mida namespace'is EI OLE
- `train_balanced`
## Mis selles sessioonis enne käivitati
| In[] | tulemus | lahtri esimene rida |
| 4 | **VIGA** KeyError ... | df = df.drop(columns=['durations']) |
| 5 | ok | df = df.drop(columns=['duration']) |
The last two sections solve most notebook errors. Missing names usually name the cause directly. The history shows the path — a skipped cell, a wrong order, or a kernel restart is as common a cause as wrong code.
Report text is in Estonian; the API and CLI flags are in English.
Commands
nberror # last error, formatted
nberror --all # every error in the log
nberror --history # last 25 executed cells
nberror-nb check nb.ipynb # static check, does not run the notebook
nberror-nb run nb.ipynb [--upto 14]
nberror-nb map nb.ipynb # cell index, line ranges, stored errors
nberror-nb line nb.ipynb 148 # which cell is line 148 in
nberror-install # auto-load in every kernel (optional)
nberror-install --check
nberror-install --uninstall
nberror-nb check finds undefined names and out-of-order cells in about a second,
without executing anything:
[DEFINEERIMATA] lahter 14, rida 4: 'train_balanced' - ei ole kusagil defineeritud
X_train_bal = train_balanced
Use with an AI agent
Put an AGENTS.md in your project telling the agent that "viga" means run
nberror and interpret the output. AGENTS.md is read without configuration by
Codex, Cursor, Copilot, Gemini CLI, Aider, Windsurf and Zed; Claude Code reads
CLAUDE.md, which can be a single line: @AGENTS.md.
Without an agent, read it yourself or pipe it anywhere:
nberror | clip # Windows
nberror | pbcopy # macOS
There is also an inline mode that calls the claude CLI and prints the
explanation straight under the cell:
import nberror; nberror.activate(inline=True)
Change MODEL, or the command in _kysi_claude, to use a different model.
Where data is kept
.nberror/ajalugu.jsonl |
error log, last 200 errors, in your project root |
~/.ipython/profile_default/history.sqlite |
IPython's own input history — read only |
Only failing cells are logged, so a successful cell costs nothing. "What ran before" comes from IPython's existing history database, which is opened read-only and never written to.
The log contains your code. Add .nberror/ to .gitignore.
Python API
import nberror
nberror.activate(inline=False, quiet=False)
nberror.deactivate()
nberror.last_error() # dict, or None
nberror.format_error(entry) # markdown string
nberror.log_path()
nberror.inputs(session, upto_line, count)
License
MIT
Release files for nberror 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nberror-0.1.0.tar.gz | 14.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nberror-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.9 kB
Release files / nberror-0.1.0.tar.gz
| Download URL | nberror-0.1.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93bf1900d6c94c7b933f86e9b9dce20330fda4fdd8b4e5d5cd5f1fe1f7bbb5be
|
|
BLAKE2b-256 checksum How to use checksums |
67af12075b63bb0c9f9c886354593ac0c08136cac68991c01086503542f7a4c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|
Release files / nberror-0.1.0-py3-none-any.whl
| Download URL | nberror-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9eb4beb7c95f5eff2258db862ad7299d82b631aeaf1a6057b62832ea2ca5a7ef
|
|
BLAKE2b-256 checksum How to use checksums |
2968501b608fb4b096b7e4d3072a291e56f6b06b5a93c84852e9d35de8af1853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|