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

Jinja 2 imports have been deprecated #10291

Closed
jontwo opened this issue Mar 24, 2022 · 10 comments
Closed

Jinja 2 imports have been deprecated #10291

jontwo opened this issue Mar 24, 2022 · 10 comments
Labels

Comments

@jontwo
Copy link

jontwo commented Mar 24, 2022

Describe the bug

There is an ImportError when using Sphinx with the latest version of Jinja2.

How to Reproduce

On any project:

$ pip install -U jinja2
$ make html

You get the error:

  File "/builds/venv/lib/python3.8/site-packages/sphinx/util/rst.py", line 21, in <module>
    from jinja2 import Environment, environmentfilter
ImportError: cannot import name 'environmentfilter' from 'jinja2' (/builds/venv/lib/python3.8/site-packages/jinja2/__init__.py)

Expected behavior

Sphinx builds without error.

Your project

This will work on any project

Screenshots

No response

OS

Rocky Linux 8.5

Python version

3.8.8

Sphinx version

3.5.4

Sphinx extensions

No response

Extra tools

No response

Additional context

No response

@ViktorHaag
Copy link
Contributor

What version of Jinja2 does your upgrade end up installing? I can't replicate this bug here. My system (on a blank docs project started via sphinx-quickstart) is:

  • macOS 12.3
  • Python 3.10.3
  • Sphinx 4.4.0
  • Jinja2 3.1.0

It's possible that this import issue has already been addressed by a version of Sphinx between your 3.5.4 and 4.4.0?

I can confirm that, via use of iPython, the import error with Jinja2 3.1.0 does appear:

In [2]: from jinja2 import Environment, environmentfilter
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 from jinja2 import Environment, environmentfilter

ImportError: cannot import name 'environmentfilter' from 'jinja2' (/Users/vhaag/.pyenv/versions/3.10.3/lib/python3.10/site-packages/jinja2/__init__.py)

@mdylanbell
Copy link

mdylanbell commented Mar 24, 2022

I'm also experiencing this bug (and it's breaking our builds). In our case, Jinja2 version 3.0.3 is being installed.

Sorry, I'm wrong. I think that may be from the most recent working container.

@pllim
Copy link

pllim commented Mar 24, 2022

Pinning to Jinja2<3.1 fixed it for our project. At first I thought 3.0.3 broke it too until I saw something else undoing my pin in the log; you should check again.

@mdylanbell
Copy link

@pllim Yes, I was wrong. I updated my original comment. I was mistakenly looking at our last successful container build.

@jontwo
Copy link
Author

jontwo commented Mar 24, 2022

Apologies, I thought I was on the latest Sphinx, as this was a new virtual environment. The bug goes away when I install the latest Sphinx so it must have been fixed somewhere along the way. I tried 4.0.0 and 4.0.1 but they require Jinja2<3.0. With Sphinx 4.0.2 the problem goes away, so this ticket can be closed. Many thanks for your help.

@Adam--
Copy link

Adam-- commented Mar 24, 2022

@jontwo This threw me for a loop too. I was on 2.4.4.
It looks like the version requirements for Jinja2 were originally >=2.3 and were updated to >=2.3,<3.0 in #9161. That was short lived with support for Jinja2 3.0 being added in #9162.
To work around this issue until I can use the new version of Sphinx, I just installed an older version of Jinja before installing Sphinx.

@pllim
Copy link

pllim commented Mar 24, 2022

Re: #10291 (comment) -- Forgot to say our project is pinning to sphinx<4 for a different issue. Should have clarified. Sorry!

has2k1 added a commit to jsoma/plotnine that referenced this issue Mar 25, 2022
Ref: sphinx-doc/sphinx#10291
Note: jinja2 is not a requirement that we need to directlys specify.
has2k1 added a commit to jsoma/plotnine that referenced this issue Mar 25, 2022
Ref: sphinx-doc/sphinx#10291
Note: jinja2 is not a requirement that we need to directlys specify.
lunkwill42 added a commit to Uninett/nav that referenced this issue Mar 25, 2022
An update of Jinja2 caused Sphinx 3.5.4 to break. Our docs seem to build
fine (i.e. with the same warnings/errors as before) with Sphinx 4.4.0,
so it's time to upgrade.

The issue itself is described in sphinx-doc/sphinx#10291
amotl added a commit to crate/crate-docs-theme that referenced this issue Mar 25, 2022
amotl added a commit to crate/crate-docs-theme that referenced this issue Mar 25, 2022
amotl added a commit to crate/crate-docs-theme that referenced this issue Mar 25, 2022
ErikBjare added a commit to NeuroTechX/EEG-ExPy that referenced this issue Mar 25, 2022
djgalloway pushed a commit to ceph/ceph that referenced this issue Mar 25, 2022
jpmckinney added a commit to open-contracting/extension_registry.py that referenced this issue Apr 6, 2022
phargogh added a commit to phargogh/invest that referenced this issue Apr 6, 2022
This should get around an import change in jinja2==3.1 that sphinx
doesn't seem to support yet.  See sphinx-doc/sphinx#10291

RE:natcap#933
igrr pushed a commit to espressif/esp-at that referenced this issue Apr 7, 2022
- Fixed that doc build failed due to the latest release of Jinja2 breaks Sphinx (sphinx-doc/sphinx#10291)
sbenthall pushed a commit to datactive/bigbang that referenced this issue Apr 7, 2022
catsuryuu pushed a commit to CERT-Polska/drakvuf-sandbox that referenced this issue Apr 8, 2022
# Workaround for sphinx-doc/sphinx#10291
Jinja2==2.11.3
MarkupSafe==2.0.1
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Apr 12, 2022
kniklas added a commit to kniklas/get-fx that referenced this issue Apr 13, 2022
Required to resolve failing CI pipeline due to problem reported in:
sphinx-doc/sphinx#10291
kniklas added a commit to kniklas/get-fx that referenced this issue Apr 13, 2022
Required to resolve failing CI pipeline due to problem reported in:
sphinx-doc/sphinx#10291
chrisjsewell added a commit to executablebooks/MyST-Parser that referenced this issue Apr 13, 2022
lorenzo-rovigatti added a commit to lorenzo-rovigatti/oxDNA that referenced this issue Apr 20, 2022
grahamgower added a commit to grahamgower/demes-spec that referenced this issue Apr 22, 2022
grahamgower added a commit to grahamgower/demes-spec that referenced this issue Apr 22, 2022
njzjz added a commit to njzjz/dpgen that referenced this issue Apr 24, 2022
AnguseZhang pushed a commit to deepmodeling/dpgen that referenced this issue Apr 24, 2022
* doc: dpgen run machine parameters

* unpin sphinx

Fix sphinx-doc/sphinx#10291 (comment)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2022
tjwebb added a commit to GoogleCloudPlatform/dataflow-geobeam that referenced this issue Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants