nbconvert ipynb to pdf returns io error

Created on 30 Nov 2016  路  7Comments  路  Source: jupyter/nbconvert

Jays-MacBook-Pro:cormen jkarimi91$ jupyter nbconvert --to pdf graphs-sssp/dijkstra.ipynb
[NbConvertApp] Converting notebook graphs-sssp/dijkstra.ipynb to pdf
[NbConvertApp] Writing 14398 bytes to notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running pdflatex 3 times: [u'pdflatex', u'notebook.tex']
[NbConvertApp] CRITICAL | pdflatex failed: [u'pdflatex', u'notebook.tex']
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./notebook.tex
LaTeX2e <2015/01/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))))
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/adjustbox.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2015/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/adjcalc.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/trimclip.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/collectbox/collectbox.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/tc-pdftex.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/ifoddpage/ifoddpage.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/varwidth/varwidth.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/color.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg))
(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/enumerate.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/eurosym/eurosym.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/utf8x.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/grffile.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty))

Package hyperref Message: Driver (autodetected): hpdftex.

(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/longtable.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/booktabs/booktabs.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/ulem/ulem.sty)
No file notebook.aux.
(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/grfext.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex

Package geometry Warning: The marginal notes overrun the paper.
     Add 3.73001pt and more to the right margin.

*geometry* verbose mode - [ preamble ] result:
* driver: pdftex
* paper: <default>
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes:
* h-part:(L,W,R)=(72.26999pt, 469.75502pt, 72.26999pt)
* v-part:(T,H,B)=(72.26999pt, 650.43001pt, 72.26999pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=469.75502pt
* \textheight=650.43001pt
* \oddsidemargin=0.0pt
* \evensidemargin=0.0pt
* \topmargin=-37.0pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=10.0pt
* \footskip=30.0pt
* \marginparwidth=65.0pt
* \marginparsep=11.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)

(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/ucsencs.def)
(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsb.fd)

LaTeX Warning: No \author given.

! Missing $ inserted.
<inserted text>
                $
l.255 \$}{Dijkstra \$ O((V + E) V) \$}}
                                       \label{dijkstra-ov-e-v}
?
! Emergency stop.
<inserted text>
                $
l.255 \$}{Dijkstra \$ O((V + E) V) \$}}
                                       \label{dijkstra-ov-e-v}
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on notebook.log.

[NbConvertApp] Running bibtex 1 time: [u'bibtex', u'notebook']
[NbConvertApp] WARNING | bibtex had problems, most likely because there were no citations
[NbConvertApp] Running pdflatex 3 times: [u'pdflatex', u'notebook.tex']
[NbConvertApp] CRITICAL | pdflatex failed: [u'pdflatex', u'notebook.tex']
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./notebook.tex
LaTeX2e <2015/01/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))))
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/adjustbox.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2015/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/adjcalc.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/trimclip.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/collectbox/collectbox.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/adjustbox/tc-pdftex.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/ifoddpage/ifoddpage.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/varwidth/varwidth.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/color.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg))
(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/enumerate.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/eurosym/eurosym.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/utf8x.def))
(/usr/local/texlive/2015/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/grffile.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty))

Package hyperref Message: Driver (autodetected): hpdftex.

(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/longtable.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/booktabs/booktabs.sty)
(/usr/local/texlive/2015/texmf-dist/tex/generic/ulem/ulem.sty) (./notebook.aux)
(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/grfext.sty)
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex

Package geometry Warning: The marginal notes overrun the paper.
     Add 3.73001pt and more to the right margin.

*geometry* verbose mode - [ preamble ] result:
* driver: pdftex
* paper: <default>
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes:
* h-part:(L,W,R)=(72.26999pt, 469.75502pt, 72.26999pt)
* v-part:(T,H,B)=(72.26999pt, 650.43001pt, 72.26999pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=469.75502pt
* \textheight=650.43001pt
* \oddsidemargin=0.0pt
* \evensidemargin=0.0pt
* \topmargin=-37.0pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=10.0pt
* \footskip=30.0pt
* \marginparwidth=65.0pt
* \marginparsep=11.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)

(/usr/local/texlive/2015/texmf-dist/tex/latex/ucs/ucsencs.def)
(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./notebook.out) (./notebook.out)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2015/texmf-dist/tex/latex/amsfonts/umsb.fd)

LaTeX Warning: No \author given.

! Missing $ inserted.
<inserted text>
                $
l.255 \$}{Dijkstra \$ O((V + E) V) \$}}
                                       \label{dijkstra-ov-e-v}
?
! Emergency stop.
<inserted text>
                $
l.255 \$}{Dijkstra \$ O((V + E) V) \$}}
                                       \label{dijkstra-ov-e-v}
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on notebook.log.

Traceback (most recent call last):
  File "//anaconda/bin/jupyter-nbconvert", line 6, in <module>
    main()
  File "//anaconda/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "//anaconda/lib/python2.7/site-packages/traitlets/config/application.py", line 596, in launch_instance
    app.start()
  File "//anaconda/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 289, in start
    self.convert_notebooks()
  File "//anaconda/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 412, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "//anaconda/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 383, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources)
  File "//anaconda/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 335, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "//anaconda/lib/python2.7/site-packages/nbconvert/exporters/exporter.py", line 165, in from_filename
    return self.from_notebook_node(nbformat.read(f, as_version=4), resources=resources, **kw)
  File "//anaconda/lib/python2.7/site-packages/nbconvert/exporters/pdf.py", line 152, in from_notebook_node
    raise IOError("PDF creating failed")
IOError: PDF creating failed

Most helpful comment

I could not find any missing $, in fact, I could find no typos at all; the ipynb renders perfectly in the browser.

So I took your suggestion and converted the ipynb to latex (the original ipynb contained github flavored markdown with inline mathjax) and inspected the tex file in a tex editor. It looks like nbconvert is not properly parsing the inline mathjax:

ipynb: * good for sparse graphs i.e. $ E = o(V^2 / \lg V) $
tex(actual): \item good for sparse graphs i.e. \$ E = o(V\^{}2 / \lg V) \$
tex(expected): \item good for sparse graphs i.e. $ E = o(V^{2} / \lg V) $

I did some investigating and came across this stack overflow post; it turns out that pandoc will not recognize the inline mathjax if either:
1) the opening $ is followed by a space or
2) the closing $ is preceded by a space

After removing the problematic spaces, I was able to resolve the --to latex issue, which in turn, resolved the --to pdf issue.
Per your request, I also verified that nbconvert --to pdf works from outside directory.

Do you think this space sensitivity is a design decision made by pandoc or a bug that should be reported to them?

All 7 comments

This appears to be the same as issue #326. I think nbconvert would attempt to open a file graphs-sssp/notebook.tex for writing inside a temporary directory, which will fail because the subdirectory graphs-sssp/ does not exist there.

Try running cd graphs-sssp and then jupyter nbconvert --to pdf dijkstra.ipynb

@dunnl I tried your suggestion but I received the same IO error as before

I read your post too quickly. It looks like the error is with the generated LaTeX. (Missing $ inserted. followed by Fatal error occurred, no output PDF file produced!). Look closely at your LaTeX source in your notebook for a missing $. It might be helpful to compile the notebook --to latex and opening that file in a LaTeX editor.

I'm a bit surprised that nbconvert has gotten as far as trying to compile the LaTeX given the issue I mentioned above. If you past your current issue, please let us know whether compiling --to pdf works when calling from another directory as you first tried.

I could not find any missing $, in fact, I could find no typos at all; the ipynb renders perfectly in the browser.

So I took your suggestion and converted the ipynb to latex (the original ipynb contained github flavored markdown with inline mathjax) and inspected the tex file in a tex editor. It looks like nbconvert is not properly parsing the inline mathjax:

ipynb: * good for sparse graphs i.e. $ E = o(V^2 / \lg V) $
tex(actual): \item good for sparse graphs i.e. \$ E = o(V\^{}2 / \lg V) \$
tex(expected): \item good for sparse graphs i.e. $ E = o(V^{2} / \lg V) $

I did some investigating and came across this stack overflow post; it turns out that pandoc will not recognize the inline mathjax if either:
1) the opening $ is followed by a space or
2) the closing $ is preceded by a space

After removing the problematic spaces, I was able to resolve the --to latex issue, which in turn, resolved the --to pdf issue.
Per your request, I also verified that nbconvert --to pdf works from outside directory.

Do you think this space sensitivity is a design decision made by pandoc or a bug that should be reported to them?

I would guess it's a deliberate decision, so that it doesn't treat it as an equation when you write something like prices range from $5 to $8. But I don't know that for certain, so if you want to ask, don't let me stop you.

I believe @takluyver is correct. Pandoc supports a Markdown extension tex_math_dollars, (enabled by default, as it happens) which is presumably the basis of LaTeX support in Jupyter notebooks. From the Pandoc user manual

the closing $ must have a non-space character immediately to its left

I'm going to close this as addressed since it's part of the core pandoc docs.

Was this page helpful?
0 / 5 - 0 ratings