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

'jinja2.utils' has no attribute 'escape' #110

Closed
robelgeda opened this issue Mar 27, 2022 · 2 comments · Fixed by #111 or #113
Closed

'jinja2.utils' has no attribute 'escape' #110

robelgeda opened this issue Mar 27, 2022 · 2 comments · Fixed by #111 or #113
Labels
Bug Something isn't working Documentation Improvements or additions to documentation Resolved ✓ Tracker
Milestone

Comments

@robelgeda
Copy link
Contributor

There is a bug with nbconvert that is causing tests to fail.

Bug

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbsphinx.py", line 1032, in parse
    rststring, resources = exporter.from_notebook_node(nb, resources)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/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/petrofit/conda/v0.4.0/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 "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/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/petrofit/conda/v0.4.0/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/petrofit/conda/v0.4.0/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/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
    {%- block body -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 29, in block 'body'
    {%- block body_loop -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/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/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 34, in block 'any_cell'
    {%- block codecell scoped -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 44, in block 'codecell'
    {%- block output_group -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 48, in block 'output_group'
    {%- block outputs scoped -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 50, in block 'outputs'
    {%- block output scoped -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/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/petrofit/conda/v0.4.0/lib/python3.10/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/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbconvert/filters/ansi.py", line 60, in ansi2html
    text = jinja2.utils.escape(text)
AttributeError: module 'jinja2.utils' has no attribute 'escape'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/cmd/build.py", line 284, in build_main
    app.build(args.force_all, filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/application.py", line 337, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    self.build(to_build,
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 308, in build
    updated_docnames = set(self.read())
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 415, in read
    self._read_serial(docnames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 436, in _read_serial
    self.read_doc(docname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 476, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/io.py", line 189, in read_doc
    pub.publish()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/docutils/core.py", line 217, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/io.py", line 109, in read
    self.parse()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbsphinx.py", line 1041, in parse
    raise NotebookError(type(e).__name__ + ' in ' +
nbsphinx.NotebookError: AttributeError in correction_grids.ipynb:
module 'jinja2.utils' has no attribute 'escape'

Notebook error:
AttributeError in correction_grids.ipynb:
module 'jinja2.utils' has no attribute 'escape'

Ticket Tracking Bug

jupyter/nbconvert#1736

Solution

For now, I will add a patch that will restrict the new version of 'jinja2.utils' that is causing this issue. The hope is that nbconvert releases a patched up version and we can remove the patch. I will keep this ticket open as a reminder to remove the patch.

@robelgeda robelgeda added the Bug Something isn't working label Mar 27, 2022
@robelgeda
Copy link
Contributor Author

Re-openning and keeping open until nbconvert releases with a fix.

@robelgeda robelgeda reopened this Mar 27, 2022
@robelgeda robelgeda added Tracker Resolved ✓ Documentation Improvements or additions to documentation labels Mar 27, 2022
@robelgeda robelgeda added this to the v0.4.1 milestone Mar 28, 2022
@robelgeda
Copy link
Contributor Author

Working again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Documentation Improvements or additions to documentation Resolved ✓ Tracker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant