Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in docs example: Using nbconvert as a library: KeyError: 'template_paths' #2081

Open
psychemedia opened this issue Dec 13, 2023 · 1 comment

Comments

@psychemedia
Copy link

psychemedia commented Dec 13, 2023

In the docs, an example is given of using nbconvert as a library:

import nbformat
from nbconvert import RSTExporter

# Instantiate exporter
rst_exporter = RSTExporter()

# Read notebook
nb = nbformat.read("demo.ipynb", as_version=4)

# Create exporter
rst_exporter = RSTExporter()

# Export notebook to rst
(body, resources) = rst_exporter.from_notebook_node(nb)
body

This throws an error:

KeyError                                  Traceback (most recent call last)
File [~/Library/Python/3.11/lib/python/site-packages/traitlets/traitlets.py:633] in TraitType.get(self, obj, cls)
    [632] try:
--> [633]  value = obj._trait_values[self.name]
    [634] except KeyError:
    [635]  # Check for a dynamic initializer.

KeyError: 'template_paths'

Running the CLI command works fine.

@psychemedia
Copy link
Author

Ah.. I wonder if this is a path problem across various python installations, perhaps with env vars pointing to one Jupyter installation but the code actually running against nbconvert in another environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant