jupyter / nbformat

Reference implementation of the Jupyter Notebook format
http://nbformat.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
265 stars 152 forks source link

Unable to covert Julia Notebook to PDF #316

Closed sthau closed 7 months ago

sthau commented 2 years ago

Hi! I'm trying to convert a Julia .ipynb to a PDF, but am getting the following error, saying that the notebook is invalid.

[NbConvertApp] Converting notebook problem_set_2.ipynb to latex
[NbConvertApp] ERROR | Notebook is invalid after preprocessor <nbconvert.preprocessors.svg2pdf.SVG2PDFPreprocessor object at 0x10f1b42b0>
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-nbconvert", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/jupyter_core/application.py", line 269, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 978, in launch_instance
    app.start()
  File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 426, in start
    self.convert_notebooks()
  File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 600, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 563, in convert_single_notebook
    output, resources = self.export_single_notebook(
  File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 491, in export_single_notebook
    output, resources = self.exporter.from_filename(
  File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 190, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 207, in from_file
    return self.from_notebook_node(
  File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/latex.py", line 74, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 386, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 147, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 344, in _preprocess
    self._validate_preprocessor(nbc, preprocessor)
  File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 311, in _validate_preprocessor
    nbformat.validate(nbc)
  File "/usr/local/lib/python3.9/site-packages/nbformat/validator.py", line 503, in validate
    raise error
nbformat.validator.NotebookValidationError: data.cells[{data__cells_x}] must be valid exactly by one definition (0 matches found)

Failed validating <unset> in notebook['data']['cells']:

On instance:
<unset>

I'm not quite sure how to handle this. Any tips?

blink1073 commented 2 years ago

Hi @sthau, can you please ensure that you are using nbformat 5.7? pip install "nbformat==5.7". With it, you should see a more informative error message.

sthau commented 2 years ago

Hi! Thanks for the quick response. I tried this, and actually got a less informative error message: it gave me the same error as before but with a truly massive string of text afterwords.

Any ideas as to what might be going on without the more informative error?

blink1073 commented 2 years ago

You can try seeing if that specific preprocecessor is causing issues by using --SVG2PDFPreprocessor.enabled=False in your command or in a config file as c.SVG2PDFPreprocessor.enabled=False.