MyST-NB is a Sphinx extension that enables direct parsing and execution of Jupyter Notebooks (.ipynb) within Sphinx documentation. It builds upon the MyST Markdown parser, allowing users to write rich technical documentation that seamlessly integrates executable code, outputs, and MyST Markdown syntax. The library maintains an active development cycle, with new versions released regularly to enhance features and ensure compatibility with the latest Python and Sphinx versions.
pip install myst-nbVerified import paths — ran on the pinned version, not inferred.
To quickly get started, install MyST-NB and add 'myst_nb' to the `extensions` list in your Sphinx `conf.py`. You can then create MyST Markdown files (`.md`) or Jupyter Notebooks (`.ipynb`) containing code cells, which MyST-NB will parse and execute during the Sphinx build process. The `glue` function allows embedding variables directly into your narrative text.
Review the MyST-NB v1.0.0 changelog and documentation for updated configuration options. Update your `conf.py` to use the new `nb_` prefixed options and explicitly enable `dollarmath` if needed: `myst_enable_extensions = ["dollarmath"]`. For cell-level configuration, the top-level key `render` has been deprecated in favor of `mystnb`.
If your project uses `ipywidgets`, ensure it is explicitly added to your project's `requirements.txt` or installed separately: `pip install ipywidgets`.
Custom renderers will need to be rewritten to align with the new plugin system (`myst_nb.renderers` and `myst_nb.mime_renderers` entry points). Consult the API documentation for the updated structure and plugin system.
Only include `'myst_nb'` in your `conf.py` `extensions` list. Do not add `'myst_parser'`. All configuration options for `myst_parser` will still be processed when `myst_nb` is active.
When debugging errors in `.ipynb` files, interpret `LINE_NUMBER` by taking `error_line_number % 10000`. The `CELL_INDEX` can be derived from `floor(error_line_number / 10000)`.
Install the package using pip: `pip install myst-nb`
Remove `myst_parser` from the `extensions` list in your `conf.py` file, keeping only `myst_nb`: `extensions = [..., 'myst_nb']`
Ensure `myst_nb` is added to your `extensions` list in `conf.py`: `extensions = [..., 'myst_nb']`
Ensure all related packages (Sphinx, myst-nb, myst-parser, docutils) are up-to-date and compatible. Try upgrading them: `pip install --upgrade sphinx myst-nb myst-parser docutils`.