无法将 ipython 笔记本转换为 pdf [英] Cannot convert ipython notebook to pdf

查看:30
本文介绍了无法将 ipython 笔记本转换为 pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm running into an error during conversion from Jupyter Notebook to PDF:

nbconvert failed: PDF creating failed

Then I tried running the pdf-converter from the command line and received the following error:

! Missing $ inserted.
<inserted text>
                $
l.291 ... Till att börja med har vi $frac{1}{2}

?
! Emergency stop.
<inserted text>
                $
l.291 ... Till att börja med har vi $frac{1}{2}

!  ==> Fatal error occurred, no output PDF file produced!

I then get a line of exceptions ending with:

OSError: PDF creating failed

I have looked through the document and I found no unmatched $ anywhere.

解决方案

Jupyter converts a notebook to PDF by first converting it to LaTeX, and then using your local latex to convert it to pdf. You get this error because there is an unmatched $ sign in the LaTeX document nbconvert creates, and the error message you see is actually latex failing because of it.

You could try converting the document in two steps. First run

jupyter nbconvert thenotebook.ipynb --to latex

Then examine the LaTeX file around line 291 to see if there is indeed an unmatched $. My guess is you will find one. When you found and corrected it, you can do the second step and convert it to pdf with latex:

latex thenotebook.tex

If you cannot find the $ symbol in the LaTeX document, you should expand the question with the lines surrounding line 291 so that we can help.

这篇关于无法将 ipython 笔记本转换为 pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆