nbsphinx
nbsphinx copied to clipboard
New jinja release leads to attributeerror?
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/lib/python3.8/site-packages/nbsphinx.py", line 1032, in parse
rststring, resources = exporter.from_notebook_node(nb, resources)
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/lib/python3.8/site-packages/nbsphinx.py", line 849, in from_notebook_node
rststr, resources = super(Exporter, self).from_notebook_node(
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/lib/python3.8/site-packages/nbconvert/exporters/templateexporter.py", line 392, in from_notebook_node
output = self.template.render(nb=nb_copy, resources=resources)
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/lib/python3.8/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/lib/python3.8/site-packages/jinja2/environment.py", line 926, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 128, in top-level template code
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/rst/index.rst.j2", line 1, in top-level template code
{%- extends 'display_priority.j2' -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code
{%- extends 'base/null.j2' -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
{%- block body -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 29, in block 'body'
{%- block body_loop -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 31, in block 'body_loop'
{%- block any_cell scoped -%}
File "<template>", line 17, in block 'any_cell'
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 34, in block 'any_cell'
{%- block codecell scoped -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 44, in block 'codecell'
{%- block output_group -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 48, in block 'output_group'
{%- block outputs scoped -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 50, in block 'outputs'
{%- block output scoped -%}
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/share/jupyter/nbconvert/templates/base/null.j2", line 54, in block 'output'
{%- block stream scoped -%}
File "<template>", line 152, in block 'stream'
File "<template>", line 138, in block 'nboutput'
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/lib/python3.8/site-packages/jinja2/runtime.py", line 777, in _invoke
rv = self._func(*arguments)
File "<template>", line 66, in template
File "/home/docs/checkouts/readthedocs.org/user_builds/scvi/envs/1459/lib/python3.8/site-packages/nbconvert/filters/ansi.py", line 60, in ansi2html
text = jinja2.utils.escape(text)
AttributeError: module 'jinja2.utils' has no attribute 'escape'
We're seeing this too in https://github.com/scikit-hep/pyhf/issues/1823
Due to this change: https://github.com/pallets/jinja/commit/824b4d3e5bb789cabd7cef74e57f4d802a7b2bfd
Probably can replace jinja.utils.escape with from markupsafe import escape
This has been reported to nbconvert in https://github.com/jupyter/nbconvert/issues/1736, and it has been fixed in https://github.com/jupyter/nbconvert/pull/1737, which should be available in the latest nbconvert release 6.4.5.
Please upgrade nbconvert.
If it still doesn't work, please let me know!
See also https://github.com/sphinx-doc/sphinx/issues/10289, https://github.com/pallets/jinja/issues/1626
This has been reported to
nbconvertin jupyter/nbconvert#1736, and it has been fixed in jupyter/nbconvert#1737, which should be available in the latestnbconvertrelease 6.4.5.Please upgrade
nbconvert.
Thanks for this information @mgeier. nbconvert v6.4.5 is indeed fixing things in https://github.com/scikit-hep/pyhf/pull/1837.
Given this, would you be open to updating/adding nbsphinx's lower bounds on nbconvert
https://github.com/spatialaudio/nbsphinx/blob/80d9b2636164c69a21c588e3a0e6d15ca74ded01/setup.py#L16-L23
to make it easier for the dependency solvers to avoid these sorts of conflicts?
I'm hesitant to add a lower bound to nbconvert because old versions of nbconvert work perfectly fine with old versions of jinja2. It's only a certain combination of versions that doesn't work. I don't know if that's possible to express in ~conf.py~ [UPDATE: I meant setup.py].
I made Issue #645 so that this Issue doesn't get drawn off topic and become less useful to other people coming here for the original motivation. Apologies in advance if this feels spammy or forceful (not the intent!).