Registry / web-framework / myst-nb

myst-nb

JSON →
library1.4.0pypypi✓ verified 21d ago

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-nb
INSTALL
IMPORT
SIG · MYST-NB
M
myst-nb
web-frameworkpythonv1.4.0
Install
14.4s avg
Import
Disk
219MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 228.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 14.4s · import 0.000s · 210MB
219MB installed
● package 219MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

myst_nb
extensions = ['myst_nb'] # in conf.py
import myst_nb # Not typically imported directly in Python code for Sphinx extension usage
MyST-NB is primarily used as a Sphinx extension by adding 'myst_nb' to the `extensions` list in `conf.py`.
glue
from myst_nb import glue
Used for 'gluing' variables from code cells into the narrative text.

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.

import os # --- conf.py (Sphinx configuration file) --- # project = 'MyST-NB Quickstart' # copyright = '2026, Your Name' # extensions = [ # 'myst_nb', # 'sphinx.ext.autodoc', # Example standard Sphinx extension # ] # # Optional: Configure notebook execution # # nb_execution_mode = "auto" # 'auto', 'off', 'force', 'cache' # # nb_execution_timeout = 60 # --- example.md (MyST Markdown file with code cells) --- example_md_content = ''' # MyST-NB Example Document This is a MyST Markdown file demonstrating executable code cells. ```{code-cell} python import datetime print("Hello from MyST-NB!") print(f"Current time: {datetime.datetime.now()}") ``` You can also use the `glue` functionality to embed variables from executed cells. ```{code-cell} python from myst_nb import glue my_result = "This value was 'glued' from a Python cell." glue("my_embedded_string", my_result) ``` The result embedded from the code cell is: {glue:text}`my_embedded_string`. ''' # To run this, you would typically: # 1. Create a Sphinx project (e.g., `sphinx-quickstart`) # 2. Modify `conf.py` as commented above # 3. Create `example.md` with the content above # 4. Build with `sphinx-build -b html . _build` # This snippet simulates saving the content to files for demonstration. # In a real Sphinx project, these files would exist in your source directory. # (Not actually running sphinx-build here, just showing file content) print("--- Simulated conf.py content ---") print("# See comments in code for full conf.py example") print("extensions = ['myst_nb']") print("\n--- Simulated example.md content ---") print(example_md_content)
Debug
Known issues
breakingBreaking changes were introduced in v1.0.0, including significant changes to configuration option names. Many options that previously did not have a prefix now use `nb_` (e.g., `jupyter_execute_notebooks` became `nb_execution_mode`). `nb_render_priority` was removed and replaced by `nb_mime_priority_overrides` with a different format. The `dollarmath` MyST extension is no longer enabled by default.
fix
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`.
affects: >=1.0.0
breakingThe `ipywidgets` package was removed as a direct dependency in v1.0.0. If your documentation relies on interactive ipywidgets, they will no longer function unless `ipywidgets` is explicitly installed in your environment.
fix
If your project uses `ipywidgets`, ensure it is explicitly added to your project's `requirements.txt` or installed separately: `pip install ipywidgets`.
affects: >=1.0.0
breakingThe internal AST structure and rendering plugin system were completely rewritten in v1.0.0 for compatibility with new Docutils functionality. Any custom renderers or direct manipulation of MyST-NB's internal Docutils AST nodes will likely break.
fix
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.
affects: >=1.0.0
gotchaMyST-NB automatically activates the `myst_parser` extension. Explicitly including `myst_parser` in your `extensions` list alongside `myst_nb` will cause conflicts or redundant processing.
fix
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.
affects: All versions
gotchaWhen MyST-NB processes Jupyter Notebooks (.ipynb), Sphinx error reporting for these files uses a special line number format: `<CELL_INDEX> * 10000 + LINE_NUMBER`. This can make pinpointing the exact line in a notebook cell challenging without understanding the format.
fix
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)`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'myst-nb'
The `myst-nb` package has not been installed in the Python environment where Sphinx is being run, or the environment is not correctly activated.
fix
Install the package using pip: `pip install myst-nb`
ValueError: list.remove(x): x not in list
This error often occurs when both `myst_parser` and `myst_nb` extensions are enabled in Sphinx's `conf.py`. `myst_nb` internally loads `myst_parser`, leading to a conflict when `myst_parser` attempts to remove a transform that `myst_nb` has already handled.
fix
Remove `myst_parser` from the `extensions` list in your `conf.py` file, keeping only `myst_nb`: `extensions = [..., 'myst_nb']`
Unknown directive type: 'code-cell' [myst.directive_unknown]
The `{code-cell}` directive is specific to `myst-nb` and will not be recognized if the `myst_nb` Sphinx extension is not correctly enabled in your `conf.py`.
fix
Ensure `myst_nb` is added to your `extensions` list in `conf.py`: `extensions = [..., 'myst_nb']`
AttributeError: 'MarkdownIt' object has no attribute 'reporter'
This error typically indicates an incompatibility or an internal state issue, often stemming from version mismatches between `myst-nb`, `myst-parser`, and Sphinx, or an incorrect setup of the Sphinx environment where parsing is occurring.
fix
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`.
Upgrade
Version history
1.4.0latest on PyPI · released Mar 2, 2026
Audit
Dependencies
sphinxrequiredCore dependency as MyST-NB is a Sphinx extension.
myst-parserrequiredMyST-NB is built on top of MyST-Parser and automatically includes it.
ipywidgetsoptionalRemoved as a direct dependency in v1.0.0. Install separately if needed for interactive widgets.
Agent activity
7 hits · last 30 days
node
6
Resources
myst-nb — pip install myst-nb · libregistry