简体   繁体   English

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

[英]Error embedding image in jupyter and exporting it to PDF with nbconvert

I have a Jupyter notebook and I am exporting it with nbconvert to PDF.我有一个 Jupyter 笔记本,我用 nbconvert 将它导出到 PDF。 When I do it, if I incorporate images, it gives me an error.当我这样做时,如果我合并图像,它会给我一个错误。

I do it with edit -> insert image, and save the image in the same folder as my jupyter document.我使用编辑-> 插入图像来完成,并将图像保存在与我的 jupyter 文档相同的文件夹中。 The cell is Markdown.单元格为 Markdown。

I show my code to see the error:我显示我的代码以查看错误:

![Captura%20de%20pantalla%20%2825%29.png](attachment:Captura%20de%20pantalla%20%2825%29.png)

When exporting it with nbconvert with the statement使用 nbconvert 导出时,使用语句

jupyter nbconvert --to PDF --no-input REDACCION.ipynb

It gives me the following error:它给了我以下错误:

(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

This is a workaround but it genuinely works.这是一种解决方法,但它确实有效。

You need to trigger a print preview by clicking the "Print" button then to use browser "Save as PDF" to save the PDF:您需要通过单击“打印”按钮触发打印预览,然后使用浏览器“另存为 PDF”来保存 PDF: 在此处输入图像描述

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 nbconvert 将 Jupyter 笔记本导出到 PDF 时的模板 - Templates while exporting Jupyter notebook to PDF with nbconvert 将jupyter笔记本转换为pdf(彩色) - nbconvert jupyter notebook to pdf (with color) 如何在使用 nbconvert 从 Jupyter 导出为 pdf 时显示宽表的所有 DataFrame/表列? - How to show all DataFrame/ table columns for wide tables while exporting as pdf from Jupyter using nbconvert? Jupyter nbconvert 导出图表到 html 和 pdf - Jupyter nbconvert export chart to html and pdf jupyter nbconvert to PDF 引发 PermissionError: [WinError 5] - jupyter nbconvert to PDF raises PermissionError: [WinError 5] IPython nbconvert错误(ipynb到pdf) - IPython nbconvert error (ipynb to pdf) 将jupyter ipython笔记本导出为pdf - exporting jupyter ipython notebook to pdf venv / bin / python -m jupyter nbconvert失败并显示错误 - venv/bin/python -m jupyter nbconvert fails with error 仅显示从Jupyter Notebook用nbconvert创建的pdf中的特定(带标签)输入单元格 - Show only specific (tagged) input cells in pdf created with nbconvert from jupyter notebook 我需要什么降价模板,以便在使用nbconvert导出时,Jupyter笔记本中的输出单元格看起来与输入单元格不同 - What markdown template do I need such that output cells in Jupyter notebooks look different from input cells when exporting using nbconvert
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM