首页 > 解决方案 > 如何修复:Jupyter PDF 导出 PNG(在降价中)包含失败

问题描述

最后更新

在经历了一个极其痛苦的更新过程之后,主要是因为 PDF 导出使用 XeLaTeX,而我一直更喜欢 LaTeX,所以需要不同的包)......

(重要的是:我认为 pandoc 希望在包 MS 中找到everyshi.sty,但正如 CTAN 上报道的那样,它不再在该包中)

PDF 创建失败,来自服务器的此信息:

notebook.tex:1678: Unable to load picture or PDF file '
dvipdfmx:fatal: Image inclusion failed for "attachment:9e002d53-d7a5-42e1-8b51-0fdec8f4dad5.png".
No output PDF file written.

Sorry, but xelatex did not succeed.
    The log file hopefully contains the information to get MiKTeX going again:
      C:\Users\usernamehere\AppData\Local\MiKTeX\2.9\miktex\log\xelatex.log

xelatax.log 显示:

2021-06-10 08:02:26,620+0100 INFO  xelatex.core - start process: miktex-dvipdfmx.exe --miktex-enable-installer -q -E -o notebook.pdf
2021-06-10 08:02:28,594+0100 FATAL xelatex.core - Invalid argument
2021-06-10 08:02:28,594+0100 FATAL xelatex.core - Function: fwrite
2021-06-10 08:02:28,594+0100 FATAL xelatex.core - Result: 22
2021-06-10 08:02:28,594+0100 FATAL xelatex.core - Data: <no data>
2021-06-10 08:02:28,594+0100 FATAL xelatex.core - Source: Libraries\MiKTeX\TeXAndFriends\include\miktex/C4P/C4P.h:646
2021-06-10 08:02:28,594+0100 FATAL xelatex - Invalid argument
2021-06-10 08:02:28,594+0100 FATAL xelatex - Info: 
2021-06-10 08:02:28,594+0100 FATAL xelatex - Source: Libraries\MiKTeX\TeXAndFriends\include\miktex/C4P/C4P.h
2021-06-10 08:02:28,594+0100 FATAL xelatex - Line: 646
2021-06-10 08:02:28,596+0100 INFO  xelatex - this process (37528) finishes with exit code 1

然后,如果我们查看 miktex-dvipdfmx.log,我们会发现通话的另一端......

2021-06-10 08:02:26,808+0100 INFO  miktex-dvipdfmx - this process (4364) started by 'xelatex' with command line: miktex-dvipdfmx.exe --miktex-enable-installer -q -E -o notebook.pdf
2021-06-10 08:02:28,558+0100 ERROR miktex-dvipdfmx - Image inclusion failed for "attachment:9e002d53-d7a5-42e1-8b51-0fdec8f4dad5.png".
2021-06-10 08:02:28,559+0100 INFO  miktex-dvipdfmx - this process (4364) finishes with exit code 1

所以。png 的图像包含失败,它是降价单元格中的附件(先前输出的屏幕抓取,因此不必总是重新运行长时间运行的代码)。

任何人都可以确认这应该有效(我已经看到了一些东西,很久以前在降价单元格中的图像存在问题)如果是这样,请解释如何解决这个问题?

更新我 29/06/2021

从 xelatex 日志中:有一个“无效的参数消息”,上面的参数“-q -E -o”是针对 miktex-dvipdfmx.exe,但参考dvipdfmx 手册我找不到 -q、-o论据...

然后检查BASIC 手册中的 dvipddf () 和选项 -o 是输出文件名(这并不奇怪),但仍然没有 -q 选项的迹象。

这至少是一致的,但是……什么?如何?等等等等等等

2021 年 6 月 29 日更新 II

更新了 miktex;发现一个新项目,miktex-dvipdfmx-bin-x64-2,已经安装了!重新运行笔记本导出。不同的错误:

nbconvert failed: PDF creating failed, captured latex output:
Failed to run "xelatex notebook.tex -quiet" command:

notebook.tex:561: Undefined control sequence

检查我找到的 miktex-dvipdfmx.log

2021-06-10 08:02:26,808+0100 INFO  miktex-dvipdfmx - this process (4364) started by 'xelatex' with command line: miktex-dvipdfmx.exe --miktex-enable-installer -q -E -o notebook.pdf
2021-06-10 08:02:28,558+0100 ERROR miktex-dvipdfmx - Image inclusion failed for "attachment:9e002d53-d7a5-42e1-8b51-0fdec8f4dad5.png".
2021-06-10 08:02:28,559+0100 INFO  miktex-dvipdfmx - this process (4364) finishes with exit code 1

所以参数错误(大概)通过使用 miktex-dvipdfmx-bin-x64-2 解决了,现在 tex 本身还有一些其他问题

不幸的是,对 C:\ 和单独的文档驱动器的完整搜索无法找到 notebook.tex,因此这里的调查死胡同。

但是,请注意,对于没有嵌入“附件”的笔记本,PDF 导出工作正常 - 我想知道它是否根本找不到附件“文件”

jupyter 的最终错误报告为 500 服务器错误:

nbconvert failed: PDF creating failed, captured latex output:
Failed to run "xelatex notebook.tex -quiet" command:

notebook.tex:496: Undefined control sequence [17 times]
...
notebook.tex:2119: Unable to load picture or PDF file '
dvipdfmx:fatal: Image inclusion failed for "attachment:9e002d53-d7a5-42e1-8b51-0fdec8f4dad5.png".

No output PDF file written.

Sorry, but xelatex did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

  C:\Users\Julian\AppData\Local\MiKTeX\2.9\miktex\log\xelatex.log

xelatex 日志说没有数据

2021-06-29 08:30:42,590+0100 INFO  xelatex.core - start process: miktex-dvipdfmx.exe --miktex-enable-installer -q -E -o notebook.pdf
2021-06-29 08:30:43,984+0100 FATAL xelatex.core - Invalid argument
2021-06-29 08:30:43,984+0100 FATAL xelatex.core - Function: fwrite
2021-06-29 08:30:43,984+0100 FATAL xelatex.core - Result: 22
2021-06-29 08:30:43,984+0100 FATAL xelatex.core - Data: <no data>
2021-06-29 08:30:43,984+0100 FATAL xelatex.core - Source: Libraries\MiKTeX\TeXAndFriends\include\miktex/C4P/C4P.h:646
2021-06-29 08:30:43,984+0100 FATAL xelatex - Invalid argument
2021-06-29 08:30:43,984+0100 FATAL xelatex - Info: 
2021-06-29 08:30:43,984+0100 FATAL xelatex - Source: Libraries\MiKTeX\TeXAndFriends\include\miktex/C4P/C4P.h
2021-06-29 08:30:43,984+0100 FATAL xelatex - Line: 646
2021-06-29 08:30:43,986+0100 INFO  xelatex - this process (38968) finishes with exit code 1

可能相关:github nbconvert 问题

标签: jupyter-notebookpandocjupyter-labmiktex

解决方案


我在这里也遇到了同样的问题。现在我的临时解决方案就是使用 Chrome 浏览器的打印功能(另存为 pdf),但这样的页眉部分和脚注就显得如此鸡肋和烦人。


推荐阅读