I'm trying to export a notebook with collapsible headings, and have encountered a "missing template" issue. The template file is on my system, but I think the jinja Environment object is looking in the wrong place.
Here is the stack trace:
> jupyter nbconvert --to html_ch file.ipynb
[NbConvertApp] Converting notebook file.ipynb to html_ch
Traceback (most recent call last):
File "/Users/josh/miniforge3/envs/export/bin/jupyter-nbconvert", line 11, in <module>
sys.exit(main())
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/jupyter_core/application.py", line 264, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/traitlets/config/application.py", line 846, in launch_instance
app.start()
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 369, in start
self.convert_notebooks()
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 541, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 506, in convert_single_notebook
output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 435, in export_single_notebook
output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/exporters/exporter.py", line 190, in from_filename
return self.from_file(f, resources=resources, **kw)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/exporters/exporter.py", line 208, in from_file
return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/jupyter_contrib_nbextensions/nbconvert_support/exporter_inliner.py", line 31, in from_notebook_node
return super(ExporterInliner, self).from_notebook_node(
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/exporters/html.py", line 210, in from_notebook_node
return super().from_notebook_node(nb, resources, **kw)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/exporters/templateexporter.py", line 392, in from_notebook_node
output = self.template.render(nb=nb_copy, resources=resources)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/exporters/templateexporter.py", line 151, in template
self._template_cached = self._load_template()
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/nbconvert/exporters/templateexporter.py", line 362, in _load_template
return self.environment.get_template(template_file)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/jinja2/environment.py", line 997, in get_template
return self._load_template(name, globals)
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/jinja2/environment.py", line 958, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
File "/Users/josh/miniforge3/envs/export/lib/python3.10/site-packages/jinja2/loaders.py", line 566, in load
raise TemplateNotFound(name)
jinja2.exceptions.TemplateNotFound: inliner
Possibly relevant versions:
Python 3.10 (same failure occurs in another env with 3.8)
It looks like this user and this one are dealing with the same issue.
Following this answer, I solved the issue by downgrading to nbconvert 5.6.1. So my guess is something in nbconvert 6+ looks for a different path and can't find the templates.
I'm trying to export a notebook with collapsible headings, and have encountered a "missing template" issue. The template file is on my system, but I think the
jinja
Environment object is looking in the wrong place.Here is the stack trace:
Possibly relevant versions: Python 3.10 (same failure occurs in another env with 3.8)
It looks like this user and this one are dealing with the same issue.
Following this answer, I solved the issue by downgrading to
nbconvert 5.6.1
. So my guess is something in nbconvert 6+ looks for a different path and can't find the templates.