8

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.

2
  • I tried downgrading tornado and Jupyter for compatibility with reprexpy, but that didn't work either. I ended up using an alternative package, reprexlite pypi.org/project/reprexlite
    – Emy
    Commented Jul 27, 2022 at 19:54
  • 1
    Hi Emy, this was fixed in the latest version of the package. I think if you download it you should be fine.
    – Chris
    Commented Dec 10, 2022 at 22:21

3 Answers 3

9

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
2
  • That command should most likely begin %pip install ... as all install commands run inside notebooks should be like that in modern Jupyter. The magic version was added in 2019 to insure installation happens in the kernel backing the running Jupyter .ipynb file. See more about the modern %pip install command here. The second paragraph here ...
    – Wayne
    Commented Mar 29 at 20:22
  • <continued> goes into more details about why the exclamation point may lead to issues.
    – Wayne
    Commented Mar 29 at 20:22
1

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

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

 // debian linux
 conda update jupyter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.