首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在jupyter中嵌入图像并使用nbconvert将其导出为PDF时出错

在jupyter中嵌入图像并使用nbconvert将其导出为PDF时出错
EN

Stack Overflow用户
提问于 2021-04-22 17:07:25
回答 1查看 122关注 0票数 2

我有一个Jupyter笔记本,我正在用nbconvert将它导出为PDF。当我这样做的时候,如果我合并了图像,它会给我一个错误。

我使用edit -> insert image进行编辑,并将图像保存在jupyter文档所在的文件夹中。该单元格为Markdown。

我展示了我的代码来查看错误:

代码语言:javascript
运行
复制
![Captura%20de%20pantalla%20%2825%29.png](attachment:Captura%20de%20pantalla%20%2825%29.png)

当使用nbconvert和语句导出它时

代码语言:javascript
运行
复制
jupyter nbconvert --to PDF --no-input REDACCION.ipynb

它给出了以下错误:

代码语言:javascript
运行
复制
(base) C:\Users\USUARIO\Desktop\DOC BECA COLABORACIÓN\CURSO AEROPYTHON-JUPITER>jupyter nbconvert --to PDF --no-input REDACCION.ipynb
[NbConvertApp] Converting notebook REDACCION.ipynb to PDF
Traceback (most recent call last):
  File "C:\Users\USUARIO\anaconda3\Scripts\jupyter-nbconvert-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
    app.start()
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 350, in start
    self.convert_notebooks()
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 524, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 489, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\nbconvertapp.py", line 418, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\exporters\exporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\exporters\pdf.py", line 183, in from_notebook_node
    self.run_latex(tex_file)
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\exporters\pdf.py", line 153, in run_latex
    return self.run_command(self.latex_command, filename,
  File "C:\Users\USUARIO\anaconda3\lib\site-packages\nbconvert\exporters\pdf.py", line 141, in run_command
    raise raise_on_failure(
nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output:
Failed to run "xelatex notebook.tex -quiet" command:
notebook.tex:446: Unable to load picture or PDF file '
notebook.tex:469: You can't use `
notebook.tex:470: Missing $ inserted
notebook.tex:471: You can't use `
notebook.tex:473: Missing $ inserted
dvipdfmx:fatal: Image inclusion failed for "attachment:Captura%20de%20pantalla%20%2825%29.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\USUARIO\AppData\Local\MiKTeX\miktex\log\xelatex.log
EN

回答 1

Stack Overflow用户

发布于 2021-11-19 16:01:29

这是一种变通方法,但它确实有效。

您需要单击“打印”按钮触发打印预览,然后使用浏览器“另存为PDF”保存PDF:

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67210193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档