jupyter / nbconvert

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

Error while converting ipynb file to pdf using nbconvert #688

Closed Kishaan closed 7 years ago

Kishaan commented 7 years ago

Hi,

I'm trying to convert my jupyter notebook file in to a pdf file and the terminal is throwing the following error;

$ jupyter nbconvert --to pdf Experiment\ with\ python.ipynb 
[NbConvertApp] Converting notebook Experiment with python.ipynb to pdf
Traceback (most recent call last):
  File "/home/kishaan/anaconda2/bin/jupyter-nbconvert", line 11, in <module>
    load_entry_point('nbconvert==5.1.1', 'console_scripts', 'jupyter-nbconvert')()
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 305, in start
    self.convert_notebooks()
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 473, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 444, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 373, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/exporter.py", line 171, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/exporter.py", line 189, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/pdf.py", line 162, in from_notebook_node
    nb, resources=resources, **kw
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/latex.py", line 82, in from_notebook_node
    return super(LatexExporter, self).from_notebook_node(nb, resources, **kw)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/templateexporter.py", line 239, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/article.tplx", line 8, in top-level template code
    ((* extends cell_style *))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/style_ipython.tplx", line 56, in top-level template code
    ((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) )))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/base.tplx", line 6, in top-level template code
    ((*- extends 'document_contents.tplx' -*))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/document_contents.tplx", line 50, in top-level template code
    ((*- block figure scoped -*))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/skeleton/display_priority.tplx", line 5, in top-level template code
    ((*- extends 'null.tplx' -*))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/skeleton/null.tplx", line 30, in top-level template code
    ((*- block body -*))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/base.tplx", line 173, in block "body"
    ((( super() )))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/skeleton/null.tplx", line 32, in block "body"
    ((*- block any_cell scoped -*))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/skeleton/null.tplx", line 76, in block "any_cell"
    ((*- block markdowncell scoped-*))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/exporters/../templates/latex/document_contents.tplx", line 67, in block "markdowncell"
    ((( cell.source | citation2latex | strip_files_prefix | convert_pandoc('markdown', 'json',extra_args=[]) | resolve_references | convert_pandoc('json','latex'))))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/filters/filter_links.py", line 16, in resolve_references
    return applyJSONFilters([resolve_one_reference], source)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/pandocfilters.py", line 197, in applyJSONFilters
    altered = walk(altered, action, format, meta)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/pandocfilters.py", line 120, in walk
    array.append(walk(item, action, format, meta))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/pandocfilters.py", line 113, in walk
    array.append(walk(item, action, format, meta))
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/pandocfilters.py", line 124, in walk
    x[k] = walk(x[k], action, format, meta)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/pandocfilters.py", line 111, in walk
    item['c'] if 'c' in item else None, format, meta)
  File "/home/kishaan/anaconda2/lib/python2.7/site-packages/nbconvert/filters/filter_links.py", line 29, in resolve_one_reference
    target = val[2][0]
IndexError: list index out of range

The output when I run pandoc --version is;

pandoc 1.12.2.1
Compiled with texmath 0.6.5.2, highlighting-kate 0.5.5.1.
Syntax highlighting is supported for the following languages:
    actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog,
    clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d,
    diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang,
    fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc,
    javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell,
    lua, makefile, mandoc, markdown, matlab, maxima, metafont, mips, modelines,
    modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml,
    octave, pascal, perl, php, pike, postscript, prolog, python, r,
    relaxngcompact, rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql,
    sqlmysql, sqlpostgresql, tcl, texinfo, verilog, vhdl, xml, xorg, xslt, xul,
    yacc, yaml
Default user data directory: /home/kishaan/.pandoc
Copyright (C) 2006-2013 John MacFarlane
Web:  http://johnmacfarlane.net/pandoc
This is free software; see the source for copying conditions.  There is no
warranty, not even for merchantability or fitness for a particular purpose.

Any help would be much appreciated!

takluyver commented 7 years ago

I think that means that a newer version of pandoc is needed. It's currently at 1.19.x, so 1.12 is quite old.

Kishaan commented 7 years ago

Hi,

Thank you for the comment! Could you please guide me as to how to update my pandoc version?

mpacer commented 7 years ago

hi @Kishaan, there are instructions specific to your OS here: https://pandoc.org/installing.html