使用nbconvert将jupyter笔记本转换为pdf时出现“缺少$插入"错误消息 [英] 'Missing $ inserted' error message when converting jupyter notebook to pdf with nbconvert

查看:637
本文介绍了使用nbconvert将jupyter笔记本转换为pdf时出现“缺少$插入"错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用以下命令将jupyter笔记本转换为pdf时:

When attempting to convert a jupyter notebook to pdf with the following command:

jupyter nbconvert --to pdf "Search and Other Content Finding Features.ipynb"

我收到一条错误消息:

! Missing $ inserted.
<inserted text>
                $
l.380 ... Other Content Finding Features_10_0.png}

?
! Emergency stop.
<inserted text>
                $
l.380 ... Other Content Finding Features_10_0.png}

我在此处找到了一些讨论.

I've found some discussion of what that is here.

但是,我在代码中找不到这些字符.可能还有其他原因吗?

However, I can't find these characters in my code. Could there be another cause?

推荐答案

在这种情况下,问题似乎是由我笔记本的文件名引起的.我不完全了解引起问题的原因,但是上面的错误消息包含对某些文本的引用:

The problem in this case seems to have been caused by my notebook's filename. I don't fully understand what caused the problem, but the error message above includes a reference to some text:

... Other Content Finding Features_10_0.png}.

该文本包含可能导致此错误的_.我认为发生的事情是,在转换脚本中的某个位置,如果文件名中有空格,则会生成一个带有下划线的文件,如图所示,然后触发该错误. (对我来说,这似乎有点像个错误,或者至少是一个弱点).

That text includes _ which can cause this error. I think what happens is that somewhere in the conversion script, if there are spaces in the filename, a file is generated with underscores as shown, and that then triggers the error. (This seems a little bit like a bug to me, or at least a weakness).

对我有用的解决方法只是更改jupyter笔记本的文件名,不包含任何空格.然后转换就顺利进行了.

The fix that worked for me was simply to change the jupyter notebook's filename not to include any spaces. Then the conversion ran without a hitch.

这篇关于使用nbconvert将jupyter笔记本转换为pdf时出现“缺少$插入"错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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