Running reprexpy on PyCharm CE: ImportError: cannot import name 'contextfilter' from 'jinja2'

14.6k Views Asked by At

I installed reprexpy 0.3.1 on PyCharm CE but when I run it, I get the following error:

(...)
File "/Users/serena/PycharmProjects/pythonProject2/venv/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 14, in <module>
    from jinja2 import contextfilter
ImportError: cannot import name 'contextfilter' from 'jinja2' (/Users/serena/PycharmProjects/pythonProject2/venv/lib/python3.7/site-packages/jinja2/__init__.py)

Process finished with exit code 1

Following advice here and here I tried to update nbconvert in the terminal:

pip install --upgrade nbconvert

Then I restarted PyCharm CE but I keep getting the same error.

3

There are 3 best solutions below

0
On

I know it's been some time since you posted this but if you are still working on it, I added /home/USERNAME/.local/bin to my path and this fixed the issue. It looks like mini-conda didn't add it to path.

Add this to your .bashrc - assuming you're using bash and that's where you profile is stored.

# Getting Jupyter on Path
$PATH = $PATH/home/USERNAME/.local/bin
0
On

I had the same thing when using jupyter-notebook. jupyter crashed when I created a new file. solution was

 // debian linux
 conda update jupyter
2
On

What worked for me was installing a specific version of jinja2, following this GitHub comment. However, I only ran the below command and it worked -- I didn't have to match the jinja version to nbconvert:

!pip install --upgrade jinja2==3.0.3