nbviewer
nbviewer copied to clipboard
Update code for nbconvert >= 6.0 (#958, #953)
Hi,
Ran into the same problem as issue #958. I had to make several changes to get it to work; not all of them I'm fully confident with.
- had to replace
exporter_mapfrom nbconvert withget_exporterfunction.. - the
template_filein HTMLExporter didn't roll... so I updated it totemplate_name... 🤨.
Leaving out the second fix will result in the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/nbviewer/providers/base.py", line 727, in finish_notebook
self.config,
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.7/site-packages/nbviewer/render.py", line 56, in render_notebook
html, resources = exporter.from_notebook_node(nb)
File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 119, in from_notebook_node
return super().from_notebook_node(nb, resources, **kw)
File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 384, in from_notebook_node
output = self.template.render(nb=nb_copy, resources=resources)
File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 148, in template
self._template_cached = self._load_template()
File "/usr/local/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 355, in _load_template
return self.environment.get_template(template_file)
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 883, in get_template
return self._load_template(name, self.make_globals(globals))
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 857, in _load_template
template = self.loader.load(self, name, globals)
File "/usr/local/lib/python3.7/site-packages/jinja2/loaders.py", line 429, in load
raise TemplateNotFound(name)
jinja2.exceptions.TemplateNotFound: basic
While I was waiting for the docker build I fixed 2 typos from #947 .
I'm not sure if this is merge-worthy... feedback or a better solution would be appreciated.
[Edit]: also some help with solving all the weird 503 errors in the automated test is welcome. Not sure what I broke here..
Hi. IMHO, this pr is more relate to #953 And we need tests for nbconvert 5.x and 6 both i think.
For #958 how about add nbconvert<6.0 on requirements.txt ?
nbconvert<6.0
Thats definately an easier solution and also more in line with the "Why Do Today What You Can Put Off Until Tomorrow" philosophy 😂
Will file the PR if you don't beat me to it.
Hi @minrk. Should we think about moving to a nbconvert 6+ as breaking change? It's been out of a while now.