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

[BUG] module 'jinja2.utils' has no attribute 'escape' #1736

Closed
aiwalter opened this issue Mar 24, 2022 · 8 comments · Fixed by #1737
Closed

[BUG] module 'jinja2.utils' has no attribute 'escape' #1736

aiwalter opened this issue Mar 24, 2022 · 8 comments · Fixed by #1737

Comments

@aiwalter
Copy link

aiwalter commented Mar 24, 2022

Today released jinja2 version has deprecated jinja2.utils.escape.
See here: pallets/jinja#1626

Not directly, it raises on readthedocs when building docs from notebooks:
https://readthedocs.org/projects/sktime/builds/16457301/

Nbconvert version:
latest

@davidism
Copy link

davidism commented Mar 24, 2022

def ansi2html(text):
"""
Convert ANSI colors to HTML colors.
Parameters
----------
text : unicode
Text containing ANSI colors to convert to HTML
"""
text = jinja2.utils.escape(text)
return _ansi2anything(text, _htmlconverter)

This needs to be changed to use from markupsafe import escape.

@aiwalter
Copy link
Author

yes its this code, so actually it is coming from nbconvert package, right?

@aiwalter
Copy link
Author

can you fix it, or should I make a PR? You would have to release it then ideally soon :)

@davidism
Copy link

I am not a maintainer of this package.

@mriedem
Copy link
Contributor

mriedem commented Mar 24, 2022

We're also seeing this, not sure if it's related but I'm chalking it up to the new jinja2 3.1.0 release:

Traceback (most recent call last):

  File "/opt/conda/bin/jupyter-nbconvert", line 6, in <module>

    from nbconvert.nbconvertapp import main

  File "/opt/conda/lib/python3.8/site-packages/nbconvert/__init__.py", line 4, in <module>

    from .exporters import *

  File "/opt/conda/lib/python3.8/site-packages/nbconvert/exporters/__init__.py", line 3, in <module>

    from .html import HTMLExporter

  File "/opt/conda/lib/python3.8/site-packages/nbconvert/exporters/html.py", line 12, in <module>

    from jinja2 import contextfilter

ImportError: cannot import name 'contextfilter' from 'jinja2' (/opt/conda/lib/python3.8/site-packages/jinja2/__init__.py)

@davidism
Copy link

davidism commented Mar 24, 2022

That one was addressed here: #1624.

It looks like #1637 was merged to treat warnings as errors in tests, which is good, although it didn't seem to catch these deprecation warnings.

MetinSa added a commit to Cosmoglobe/Cosmoglobe that referenced this issue Mar 24, 2022
Fixed by setting upper limit on jinja2 dependency
scottclowe added a commit to scottclowe/fissa that referenced this issue Mar 25, 2022
The removal of jinja2.utils.escape in Jinja2 v3.1.0
breaks nbconvert, which was relying on this deprecated function.

For more details, see issue here:
jupyter/nbconvert#1736
@SylvainCorlay
Copy link
Member

cc @MSeal @davidbrochart FYI

@davidism
Copy link

nbconvert/setup.cfg

Lines 12 to 14 in 1211cb2

[tool:pytest]
markers =
network: marks tests which require network connection

If nbconvert adds filterwarnings = error to this section, they can respond proactively to warnings. The previous "warnings as errors" PR was only in relation to their own documentation builds.

bwohlberg added a commit to lanl/scico that referenced this issue Mar 25, 2022
* Add Huber function norm

* Add bisection vector root finder

* Improve error handling and tests

* Improvements

* Add golden section minimizer

* Docs correction

* Minor edits

* Add set distance functional

* Add squared set distance functional

* Clean up set distance tests

* Clean up functional tests

* Temporary fix for jinja2/nbconvert bug jupyter/nbconvert#1736

* Update change summary

* Address codefactor complaints

* Rename test file
pramodk pushed a commit to neuronsimulator/nrn that referenced this issue Mar 25, 2022
* module 'jinja2.utils' has no attribute 'escape' sphinx-doc/sphinx#10289
* [BUG] module 'jinja2.utils' has no attribute 'escape' jupyter/nbconvert#1736
Bultako added a commit to gammapy/gammapy that referenced this issue Mar 25, 2022
hkaimio added a commit to hkaimio/notebooks that referenced this issue Mar 27, 2022
This is a WAR to incompatibility issue between nbconvert latest
Jinja2, see jupyter/nbconvert#1736
rosbo added a commit to Kaggle/docker-python that referenced this issue Mar 28, 2022
The latest version of Jinja changed the import for `Markup`.

The import was fixed in the latest version of `nbconvert`: jupyter/nbconvert#1736

We include the version of `nbconvert` from the DLVM base image which is
released every ~2 weeks. However, the `nbconvert` fix was released only
6 hours ago.

Temporarily install thel latest version of `nbconvert`.

Add a test to prevent regression.

http://b/227194111
rosbo added a commit to Kaggle/docker-python that referenced this issue Mar 28, 2022
The latest version of Jinja changed the import for `Markup`.

The import was fixed in the latest version of `nbconvert`: jupyter/nbconvert#1736

We include the version of `nbconvert` from the DLVM base image which is
released every ~2 weeks. However, the `nbconvert` fix was released only
6 hours ago.

Temporarily install thel latest version of `nbconvert`.

Add a test to prevent regression.

http://b/227194111
bilke added a commit to ufz/ogs that referenced this issue Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants