A description of your project
Project Links
Meta
Author: Jeremy Howard
Requires Python: >=3.7
Classifiers
Development Status
- 3 - Alpha
Intended Audience
- Developers
Natural Language
- English
Programming Language
- Python :: 3.7
- Python :: 3.8
License
- OSI Approved :: Apache Software License
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):
from execnb.nbio import *
from execnb.shell import *
from fastcore.utils import *
s = CaptureShell()
s.run('1+1')
[{'data': {'text/plain': ['2']},
'metadata': {},
'output_type': 'execute_result',
'execution_count': 1}]
To execute a notebook and save it with outputs filled in, use
CaptureShell.execute:
try:
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': 3, '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
optional arguments:
-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.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