A description of your project
Project Links
Meta
Author: Jeremy Howard
Requires Python: >=3.7
Classifiers
Natural Language
- English
Intended Audience
- Developers
Development Status
- 2 - Pre-Alpha
Programming Language
- Python :: 3
- Python :: 3 :: Only
execnb
Install
Either:
pip install execnb
or if you use conda:
conda install -c fastai execnb
(You can replace conda with mamba in the line above if you have mamba installed.)
How to use
Use CaptureShell to run Jupyter code and capture notebook outputs, without running a Jupyter server (or even having it installed). The API is async, so await the run from a notebook or async code, or wrap it in asyncio.run at a sync entry point:
from execnb.shell import *
from fastcore.utils import *
from fastcore.nbio import *
s = CaptureShell()
await s.run('1+1')
[{'data': {'text/plain': ['2']},
'metadata': {},
'output_type': 'execute_result',
'execution_count': None}]
To execute a notebook and save it with outputs filled in, use CaptureShell.execute:
try:
await s.execute('../tests/clean.ipynb', 'tmp.ipynb')
print(read_nb('tmp.ipynb').cells[1].outputs)
finally: Path('tmp.ipynb').unlink()
[{'name': 'stdout', 'output_type': 'stream', 'text': '1\n'}, {'data': {'text/plain': '2'}, 'execution_count': None, 'metadata': {}, 'output_type': 'execute_result'}]
You can also execute notebooks from the command line with exec_nb:
!exec_nb --help
usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
[--inject_path INJECT_PATH] [--inject_idx INJECT_IDX] [--verbose]
src
Execute notebook from `src` and save with outputs to `dest`
positional arguments:
src Notebook path to read from
options:
-h, --help show this help message and exit
--dest DEST Notebook path to write to (default: )
--exc_stop Stop on exceptions? (default: False)
--inject_code INJECT_CODE Code to inject into a cell
--inject_path INJECT_PATH Path to file containing code to inject into a cell
--inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
--verbose Show stdout/stderr during execution (default:
False)
0.3.3
Aug 25, 2026
0.3.2
Aug 10, 2026
0.3.1
Aug 10, 2026
0.3.0
Aug 08, 2026
0.2.10
Aug 07, 2026
0.2.9
Jul 22, 2026
0.2.8
Jul 20, 2026
0.2.7
Jul 14, 2026
0.2.6
Jul 08, 2026
0.2.5
Jul 08, 2026
0.2.4
Jul 06, 2026
0.2.3
Jul 02, 2026
0.2.2
Apr 26, 2026
0.2.1
Apr 13, 2026
0.2.0
Apr 10, 2026
0.1.18
Jan 04, 2026
0.1.17
Jan 04, 2026
0.1.16
Dec 20, 2025
0.1.15
Oct 15, 2025
0.1.14
Apr 05, 2025
0.1.13
Apr 05, 2025
0.1.12
Mar 08, 2025
0.1.11
Dec 04, 2024
0.1.10
Dec 03, 2024
0.1.9
Dec 01, 2024
0.1.8
Nov 15, 2024
0.1.7
Nov 15, 2024
0.1.6
May 06, 2024
0.1.5
Feb 13, 2023
0.1.4
Sep 26, 2022
0.1.3
Sep 03, 2022
0.1.2
Aug 21, 2022
0.1.1
Aug 07, 2022
0.1.0
Aug 06, 2022
0.0.10
Aug 04, 2022
0.0.9
Jul 25, 2022
0.0.8
Jul 25, 2022
0.0.7
Jun 29, 2022
0.0.6
Jun 17, 2022
0.0.5
Jun 08, 2022
0.0.4
Jun 08, 2022
0.0.3
Jun 08, 2022
0.0.2
Jun 07, 2022
0.0.1
Jun 07, 2022