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] ImportError: cannot import name 'contextfilter' from 'jinja2' #46

Closed
AnirudhDagar opened this issue Mar 29, 2022 · 4 comments
Closed

Comments

@AnirudhDagar
Copy link
Member

nbconvert is pinned to version 5.6.1 in d2lbook. This older version doesn't include this fix for the earlier deprecated (and recently completely remove functions in jinja2).

Hence recently when the latest version (v3.1.0) of jinja2 was released on Mar 24, 2022, we started to get the following import error because of the removed functions like contextfilter.

ImportError: cannot import name 'contextfilter' from 'jinja2'

To fix this issue either we can pin jinja2 to 3.0 (which may not be the best idea) or we can unpin nbconvert and use the latest version which already handles the fix for removed functions.

@AnirudhDagar
Copy link
Member Author

Fixed in #47

buedaswag added a commit to LDSSA/ldsagrader that referenced this issue Apr 3, 2022
pradal added a commit to openalea/strawberry that referenced this issue May 9, 2022
pradal added a commit to openalea/strawberry that referenced this issue May 9, 2022
@clarenznet
Copy link

solved the issue by matching jinja2 version and nb convert as follows
jinja2==3.0.3
nbconvert==6.4.4

@friendlyCamel
Copy link

solved the issue by matching jinja2 version and nb convert as follows jinja2==3.0.3 nbconvert==6.4.4

it works! and a tip: 'pip' or 'conda' these two packages in 'base' env!! Because if you look in the error log, you will find the py script which jupyter app launched locate in the base env. That means the problem appeared here is not related to the virtual environment you created,but related to the base env or maybe the jupyter itself.

lorenzomag added a commit to lorenzomag/wimprates that referenced this issue Aug 7, 2024
The following error arises while `Test package` executes in the workflow.

The following suggestion was followed: d2l-ai/d2l-book#46 (comment)
lorenzomag added a commit to lorenzomag/wimprates that referenced this issue Aug 8, 2024
The following error arises while `Test package` executes in the workflow.

The following suggestion was followed: d2l-ai/d2l-book#46 (comment)
JelleAalbers pushed a commit to JelleAalbers/wimprates that referenced this issue Aug 9, 2024
* Update pytest.yml

* Update pytest.yml + fix test

Bump action versions.

Use `pip install -e .` instead of `python setup.py develop` as the latter is now deprecated.

Trying to fix issue with jinja2 being deprecated.

* Downgrade jinja for pytest.yml

The following error arises while `Test package` executes in the workflow.

The following suggestion was followed: d2l-ai/d2l-book#46 (comment)

* Update pytest.yml

Recursively checkout submodules

* Update pytest.yml

Add libraries for notebooks
@hccsgithub
Copy link

通过匹配 jinja2 版本和 nb convert 解决了该问题,如下所示 jinja2==3.0.3 nbconvert==6.4.4

thank you very much,I was going to try last time, but it work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants