jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.75k stars 569 forks source link

PDF conversion error: No filter named 'convert_explicitly_relative_paths' #2045

Closed Kevin-Mattheus-Moerman closed 11 months ago

Kevin-Mattheus-Moerman commented 1 year ago

When I try to export a notebook to a PDF (PDF via Latex option) file I get: nbconvert failed: No filter named 'convert_explicitly_relative_paths'.

Screenshot from 2023-09-21 12-41-51

I use Jupyter for teaching and I usually also share the PDF with students. Any help to address the above would be appreciated. Thanks.

More details below.

The error sounds Tex/Latex related, but I do have all dependencies installed (e.g. pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic).

I am running a Julia Jupyter notebook but I get the same for a Python on Octave kernel.

For completeness, the full output when I try it in the terminal instead using jupyter nbconvert --to PDF Untitled1.ipynb, is:

[NbConvertApp] Converting notebook Untitled1.ipynb to PDF
Traceback (most recent call last):
  File "/home/kevin/anaconda3/bin/jupyter-nbconvert", line 11, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/jupyter_core/application.py", line 277, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/traitlets/config/application.py", line 992, in launch_instance
    app.start()
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/nbconvertapp.py", line 423, in start
    self.convert_notebooks()
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/nbconvertapp.py", line 597, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/nbconvertapp.py", line 560, in convert_single_notebook
    output, resources = self.export_single_notebook(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/nbconvertapp.py", line 488, in export_single_notebook
    output, resources = self.exporter.from_filename(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/exporters/exporter.py", line 189, in from_filename
    return self.from_file(f, resources=resources, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/exporters/exporter.py", line 206, in from_file
    return self.from_notebook_node(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/exporters/pdf.py", line 181, in from_notebook_node
    latex, resources = super().from_notebook_node(nb, resources=resources, **kw)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/exporters/latex.py", line 74, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/nbconvert/exporters/templateexporter.py", line 413, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/kevin/.local/share/jupyter/nbconvert/templates/latex/index.tex.j2", line 8, in top-level template code
    ((* extends cell_style *))
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/.local/share/jupyter/nbconvert/templates/latex/style_jupyter.tex.j2", line 176, in top-level template code
    \prompt{(((prompt)))}{(((prompt_color)))}{(((execution_count)))}{(((extra_space)))}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/.local/share/jupyter/nbconvert/templates/latex/base.tex.j2", line 7, in top-level template code
    ((*- extends 'document_contents.tex.j2' -*))
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kevin/anaconda3/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/kevin/.local/share/jupyter/nbconvert/templates/latex/document_contents.tex.j2", line 68, in template
    ((( cell.source | citation2latex | strip_files_prefix | convert_pandoc('markdown+tex_math_double_backslash', 'json',extra_args=[]) | resolve_references | convert_explicitly_relative_paths | convert_pandoc('json','latex'))))
^^^^^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.TemplateAssertionError: No filter named 'convert_explicitly_relative_paths'.

More details:

Installed via: conda OS: Ubuntu 22.04.3 LTS Output of jupyter --version:

Selected Jupyter core packages...
IPython          : 8.15.0
ipykernel        : 6.25.0
ipywidgets       : 8.0.4
jupyter_client   : 7.4.9
jupyter_core     : 5.3.0
jupyter_server   : 1.23.4
jupyterlab       : 3.6.3
nbclient         : 0.5.13
nbconvert        : 6.5.4
nbformat         : 5.9.2
notebook         : 6.5.4
qtconsole        : 5.4.2
traitlets        : 5.7.1
Kevin-Mattheus-Moerman commented 1 year ago

Still stuck on this issue. Any help appreciated.

tuncbkose commented 1 year ago

Hello! Sorry about the problem you have been having. convert_explicitly_relative_paths was added to nbconvert and the default LaTeX document template in v7.5.0 (see this for details). I am not sure how you ended up with the updated template and an outdated nbconvert, but I imagine this problem can be avoided by either:

Let me know if there are any further problems.

Kevin-Mattheus-Moerman commented 11 months ago

@tuncbkose thanks. Upgrading nbconvert solved the PDF export issue relating to convert_explicitly_relative_paths. I think I had a funny set-up because I tried to get both RISE presentations and interactive Julia content to work. No luck on those. I think I have to wait for RISE to be compatible with the newer notebook formats.

Thanks for the above anyway. I'll close this one now.