jupyter / nbviewer

nbconvert as a web service: Render Jupyter Notebooks as static web pages
https://nbviewer.jupyter.org
Other
2.22k stars 551 forks source link

Unable to export to pdf #513

Open wsfreund opened 9 years ago

wsfreund commented 9 years ago

When I try to run ipython nbconvert —to pdf Creating_and_configuring_CERN_VM_for_ATLAS.ipynb (gist), I get the following error:

Underfull \hbox (badness 10000) in paragraph at lines 597--599
[]\OT1/cmr/m/n/10 ======================\OML/cmm/m/it/10 > \OT1/cmr/m/n/10 TeX
Live in-stal-la-tion pro-ce-dure
[6] [7] [8] [9]
! Missing \endcsname inserted.
<to be read again>
                   \&
l.913 ...erref[Latex-\&\#x28;TexLive-2015\&\#x29;]
                                                  {explained before here}. I
?
! Emergency stop.
<to be read again> 
                   \&
l.913 ...erref[Latex-\&\#x28;TexLive-2015\&\#x29;]
                                                  {explained before here}. I
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on notebook.log.

Traceback (most recent call last):
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/bin/ipython", line 11, in <module>
    sys.exit(start_ipython())
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/IPython/__init__.py", line 118, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/traitlets/config/application.py", line 592, in launch_instance
    app.start()
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 349, in start
    return self.subapp.start()
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 286, in start
    self.convert_notebooks()
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 409, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 380, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources)
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert/nbconvertapp.py", line 332, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert/exporters/exporter.py", line 166, in from_filename
    return self.from_notebook_node(nbformat.read(f, as_version=4), resources=resources, **kw)
  File "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert/exporters/pdf.py", line 139, in from_notebook_node
    raise RuntimeError("PDF creating failed")
RuntimeError: PDF creating failed

Debug information:

[NbConvertApp] Config changed:
[NbConvertApp] {'NbConvertApp': {'export_format': u'pdf', 'log_level': 10}}
[NbConvertApp] Searching [u'/afs/cern.ch/user/w/wsfreund/RingerProjectNBs', '/afs/cern.ch/user/w/wsfreund/.jupyter', '/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[NbConvertApp] Attempting to load config file jupyter_config.py in path /etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_config.json in path /etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_config.py in path /usr/local/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_config.json in path /usr/local/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_config.py in path /afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_config.json in path /afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_config.py in path /afs/cern.ch/user/w/wsfreund/.jupyter
[NbConvertApp] Attempting to load config file jupyter_config.json in path /afs/cern.ch/user/w/wsfreund/.jupyter
[NbConvertApp] Attempting to load config file jupyter_config.py in path /afs/cern.ch/user/w/wsfreund/RingerProjectNBs
[NbConvertApp] Attempting to load config file jupyter_config.json in path /afs/cern.ch/user/w/wsfreund/RingerProjectNBs
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.py in path /etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.json in path /etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.py in path /usr/local/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.json in path /usr/local/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.py in path /afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.json in path /afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/etc/jupyter
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.py in path /afs/cern.ch/user/w/wsfreund/.jupyter
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.json in path /afs/cern.ch/user/w/wsfreund/.jupyter
[NbConvertApp] Loaded config file: /afs/cern.ch/user/w/wsfreund/.jupyter/jupyter_nbconvert_config.py
[NbConvertApp] Config changed:
[NbConvertApp] {'NbConvertApp': {'export_format': u'pdf', 'log_level': 10}, 'Exporter': {'template_path': ['/afs/cern.ch/user/w/wsfreund/.local/share/jupyter/templates']}}
[NbConvertApp] Loaded config file: /afs/cern.ch/user/w/wsfreund/.jupyter/jupyter_nbconvert_config.json
[NbConvertApp] Config changed:
[NbConvertApp] {'NbConvertApp': {'export_format': u'pdf', 'log_level': 10, u'postprocessor_class': u'post_embedhtml.EmbedPostProcessor'}, 'Exporter': {'template_path': [u'/afs/cern.ch/user/w/wsfreund/.local/share/jupyter/templates'], u'preprocessors': [u'pre_codefolding.CodeFoldingPreprocessor', u'pre_pymarkdown.PyMarkdownPreprocessor']}}
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.py in path /afs/cern.ch/user/w/wsfreund/RingerProjectNBs
[NbConvertApp] Attempting to load config file jupyter_nbconvert_config.json in path /afs/cern.ch/user/w/wsfreund/RingerProjectNBs
/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated. You should import from ipython_nbconvert instead.
  "You should import from ipython_nbconvert instead.", ShimWarning)
[NbConvertApp] Converting notebook Creating_and_configuring_CERN_VM_for_ATLAS.ipynb to pdf
[NbConvertApp] Notebook name is 'Creating_and_configuring_CERN_VM_for_ATLAS'
[NbConvertApp] Applying preprocessor: coalesce_streams
[NbConvertApp] Applying preprocessor: SVG2PDFPreprocessor
[NbConvertApp] Applying preprocessor: LatexPreprocessor
[NbConvertApp] Applying preprocessor: HighlightMagicsPreprocessor
[NbConvertApp] Applying preprocessor: ExtractOutputPreprocessor
[NbConvertApp] Applying preprocessor: CodeFoldingPreprocessor
[NbConvertApp] Applying preprocessor: PyMarkdownPreprocessor
[NbConvertApp] Attempting to load template article.tplx
[NbConvertApp] Loaded template article.tplx
[NbConvertApp] Attempting to load template article.tplx
[NbConvertApp] Loaded template article.tplx
/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert/utils/pandoc.py:49: RuntimeWarning: You are using an old version of pandoc (1.9.4.1)
Recommended version is 1.12.1.
Try updating.http://johnmacfarlane.net/pandoc/installing.html.
Continuing with doubts...
  check_pandoc_version()
[NbConvertApp] Writing 67163 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)

# Continues with pdfTex until error.

I am using:

ipython --version                                                          
4.0.0
python --version
Python 2.7.4

and

pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015)
kpathsea version 6.2.1
Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.17; using libpng 1.6.17
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with xpdf version 3.04

I would appreciate any help on this.

minrk commented 9 years ago

Can you test with the latest master of nbconvert? There have been some fixes to latex export since the last release.

wsfreund commented 9 years ago

I have found the following packages:

~/.pyenv/versions/2.7.4/lib/python2.7/site-packages/nbconvert
~/.pyenv/versions/2.7.4/lib/python2.7/site-packages/notebook/services/nbconvert
~/.pyenv/versions/2.7.4/lib/python2.7/site-packages/notebook/nbconvert

And tried to update all of them, but only the first would have a minor update. I couldn't find the equivalent package to what (if I'm right) should be this one with recent commits. Where should I find the package and update it to HEAD?

minrk commented 9 years ago

There's only one nbconvert package. The nbconvert directories in the notebook package are web APIs that aren't relevant. Leave them as they are.

This should install the latest nbconvert:

pip install -e git+https://github.com/jupyter/nbconvert#egg=nbconvert
wsfreund commented 9 years ago

I'm having the following issue when attempting to update nbconvert. I had to install pycurl using

export PYCURL_SSL_LIBRARY="nss"
easy_install pycurl

It would them remove misleading error from here, which in fact wasn't that I hadn't it installed, but that when I tried to import it I would have:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/pycurl.py", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/pycurl.py", line 6, in __bootstrap__
ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)

But now I have this other error that I wasn't able to solve…

Installing collected packages: nbconvert
  Running setup.py develop for nbconvert
    Complete output from command /afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/bin/python2.7 -c "import setuptools, tokenize; __file__='/afs/cern.ch/user/w/wsfreund/src/nbconvert/setup.py'; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps:
    /afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/lib/python2.7/site-packages/setuptools/dist.py:285: UserWarning: Normalizing '4.1.0.dev' to '4.1.0.dev0'
      normalized_version,
    running develop
    running css
    Failed, trying again with PycURL to avoid outdated SSL.
    Failed to download css from https://cdn.jupyter.org/notebook/4.0.1/style/style.min.css: (35, 'SSL connect error')
    Downloading CSS: https://cdn.jupyter.org/notebook/4.0.1/style/style.min.css
    error: None

    ----------------------------------------
Command "/afs/cern.ch/user/w/wsfreund/.pyenv/versions/2.7.4/bin/python2.7 -c "import setuptools, tokenize; __file__='/afs/cern.ch/user/w/wsfreund/src/nbconvert/setup.py'; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop —no-deps" failed with error code 1 in /afs/cern.ch/user/w/wsfreund/src/nbconvert
wsfreund commented 9 years ago

Ok, I've managed to update by downloading by hand (wget https://cdn.jupyter.org/notebook/4.0.1/style/style.min.css) and editing the setup.py file to use the downloaded path. However, I still get the same error as I first described.