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

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

问题描述

将笔记本转换为pdf时遇到了一些麻烦.首先,我尝试在webb-app中执行此操作,然后得到了

I've got some trouble when converting a notebook to a pdf. First I tryed doing it in the webb-app and I got:

nbconvert failed: PDF creating failed

然后我尝试从cmd运行pdf转换器,这给了我很长的错误消息,但以下内容似乎是最重要的:

Then I tried running the pdf-converter from the cmd and it gave me a long error message but the following seems to be the most important:

! 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!

然后它给了我一长串异常,结尾是:

And then it gives me a long line of exceptions ending with:

OSError: PDF creating failed

我仔细阅读了文档,发现任何地方都没有匹配的$.

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

推荐答案

Jupyter首先将笔记本转换为LaTeX,然后使用本地乳胶将其转换为pdf,从而将笔记本转换为PDF.之所以会出现此错误,是因为在nbconvert创建的LaTeX文档中有一个不匹配的$符号,并且您看到的错误消息实际上是由于它而导致的乳胶失败.

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

然后检查第291行附近的LaTeX文件,以查看是否确实存在不匹配的$.我的猜测是您会找到一个.找到并更正它后,您可以执行第二步,并使用latex将其转换为pdf:

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

如果您在LaTeX文档中找不到$符号,则应使用第291行周围的行来扩展问题,以便我们提供帮助.

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天全站免登陆