{"id":21314,"library":"execnb","title":"execnb","description":"A Python library for executing Jupyter notebooks in non-interactive environments. Supports capturing outputs, rendering inline plots, and running notebooks from the command line. Current version 0.2.2, released March 2024. Maintained by AnswerDotAI, release cadence irregular.","status":"active","version":"0.2.2","language":"python","source_language":"en","source_url":"https://github.com/AnswerDotAI/execnb/","tags":["notebook","execution","jupyter","nbio","automation"],"install":[{"cmd":"pip install execnb","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Required for nbio module (moved from execnb in v0.2.0)","package":"fastcore","optional":false},{"reason":"Used for execution kernel and rich output","package":"ipython","optional":false},{"reason":"Inline plotting support (optional if mpl_format=None)","package":"matplotlib","optional":true}],"imports":[{"note":"exec_nb was moved to nbio submodule in v0.2.0","wrong":"from execnb import exec_nb","symbol":"exec_nb","correct":"from execnb.nbio import exec_nb"},{"note":"read_nb is part of nbio module","wrong":"from execnb import read_nb","symbol":"read_nb","correct":"from execnb.nbio import read_nb"},{"note":"","wrong":null,"symbol":"NBIO","correct":"from execnb.nbio import NBIO"}],"quickstart":{"code":"from execnb.nbio import exec_nb\nfrom pathlib import Path\n\n# Execute a notebook and capture outputs\nnb = exec_nb('notebook.ipynb')\nfor cell in nb.cells:\n    if cell.outputs:\n        for output in cell.outputs:\n            print(output.text if hasattr(output, 'text') else output)","lang":"python","description":"Execute a Jupyter notebook file and iterate over cell outputs."},"warnings":[{"fix":"Update imports to use execnb.nbio for exec_nb, read_nb, NBIO. If using fastcore.nbio directly, adjust accordingly.","message":"The nbio module was moved from execnb.nbio to fastcore.nbio in version 0.2.0. Code using old imports will break.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Use mpl_format=None in exec_nb to skip matplotlib setup when not needed.","message":"The old exec_nb function without specifying mpl_format may set up inline matplotlib automatically, which can interfere with headless environments.","severity":"deprecated","affected_versions":"<0.2.2"},{"fix":"Ensure notebooks are prepared for batch execution, avoiding input() calls or interactive widgets.","message":"Executing notebooks that use interactive widgets or require user input will fail. execnb is designed for non-interactive execution.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to >=0.1.17 or manually set cell IDs in the notebook metadata.","message":"Cell IDs are not extracted from cell metadata automatically in versions prior to 0.1.17. This can cause duplicate or missing cell identifiers.","severity":"gotcha","affected_versions":"<0.1.17"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install fastcore","cause":"fastcore is a dependency that must be installed separately.","error":"ModuleNotFoundError: No module named 'fastcore'"},{"fix":"Use: from execnb.nbio import exec_nb","cause":"The exec_nb function was moved to the nbio submodule in v0.2.0.","error":"ImportError: cannot import name 'exec_nb' from 'execnb'"},{"fix":"Check output type before accessing .text, e.g., output.get('text') or if hasattr(output, 'text')","cause":"Cell output may be a different type (e.g., display data) without a text attribute.","error":"AttributeError: 'NoneType' object has no attribute 'text'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}