jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.7k stars 562 forks source link

'IndexError: list index out of range' when trying to convert some jupyter notebooks. #1505

Open Hrrsmjd opened 3 years ago

Hrrsmjd commented 3 years ago

I have been able to use nbconvert to convert some .ipynb files into pdf, but there is one .ipynb file that isn't working. I suspect that it has something to do with Inkscape. I used the pandocs installer and downloaded Inkscape from https://inkscape.org/. This is the error that I am getting:

[NbConvertApp] Converting notebook mlp-week02.ipynb to pdf
Traceback (most recent call last):
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'command'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'inkscape_version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\s1612415\AppData\Local\Programs\Python\Python39\Scripts\jupyter-nbconvert.EXE\__main__.py", line 7, in <module>
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\jupyter_core\application.py", line 254, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
    app.start()
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\nbconvertapp.py", line 345, in start
    self.convert_notebooks()
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\nbconvertapp.py", line 519, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\nbconvertapp.py", line 484, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\nbconvertapp.py", line 413, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\exporters\exporter.py", line 182, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\exporters\exporter.py", line 200, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\exporters\pdf.py", line 168, in from_notebook_node
    latex, resources = super().from_notebook_node(
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\exporters\latex.py", line 77, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\exporters\templateexporter.py", line 367, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\exporters\exporter.py", line 144, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\exporters\exporter.py", line 319, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\preprocessors\base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\preprocessors\base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\preprocessors\convertfigures.py", line 45, in preprocess_cell
    output.data[self.to_format] = self.convert_figure(
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 125, in convert_figure
    shell = self.command.format(from_filename=input_filename,
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 1578, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 77, in _command_default
    major_verison = self.inkscape_version.split('.')[0]
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 1578, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "c:\users\s1612415\appdata\local\programs\python\python39\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 63, in _inkscape_version_default
    return output.decode('utf-8').split(' ')[1]
IndexError: list index out of range

I have the following packages installed:

C:\WINDOWS\system32>pip list
Package             Version
------------------- -------
argon2-cffi         20.1.0
async-generator     1.10
attrs               20.3.0
backcall            0.2.0
bleach              3.2.1
cffi                1.14.4
colorama            0.4.4
cycler              0.10.0
decorator           4.4.2
defusedxml          0.6.0
entrypoints         0.3
ipykernel           5.4.3
ipython             7.19.0
ipython-genutils    0.2.0
ipywidgets          7.6.3
jedi                0.18.0
Jinja2              2.11.2
joblib              1.0.0
jsonschema          3.2.0
jupyter             1.0.0
jupyter-client      6.1.11
jupyter-console     6.2.0
jupyter-core        4.7.0
jupyterlab-pygments 0.1.2
jupyterlab-widgets  1.0.0
kiwisolver          1.3.1
MarkupSafe          1.1.1
matplotlib          3.3.3
mistune             0.8.4
nbclient            0.5.1
nbconvert           6.0.0
nbformat            5.1.0
nest-asyncio        1.4.3
notebook            6.2.0
numpy               1.19.5
packaging           20.8
pandas              1.2.0
pandocfilters       1.4.3
parso               0.8.1
pickleshare         0.7.5
Pillow              8.1.0
pip                 20.3.3
ply                 3.11
prometheus-client   0.9.0
prompt-toolkit      3.0.10
pycparser           2.20
Pygments            2.7.4
pyparsing           2.4.7
pyrsistent          0.17.3
python-dateutil     2.8.1
pytz                2020.5
pywin32             300
pywinpty            0.5.7
pyzmq               21.0.0
qtconsole           5.0.1
QtPy                1.9.0
scikit-learn        0.24.0
scipy               1.6.0
seaborn             0.11.1
Send2Trash          1.5.0
setuptools          49.2.1
six                 1.15.0
terminado           0.9.2
testpath            0.4.4
threadpoolctl       2.1.0
tornado             6.1
traitlets           5.0.5
wcwidth             0.2.5
webencodings        0.5.1
widgetsnbextension  3.5.1

C:\WINDOWS\system32>pandoc --version
pandoc 2.11.3.2
Compiled with pandoc-types 1.22, texmath 0.12.1, skylighting 0.10.2,
citeproc 0.3.0.3, ipynb 0.1.0.1
User data directory: C:\Users\s1612415\AppData\Roaming\pandoc
Copyright (C) 2006-2020 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
netotz commented 3 years ago

were you able to solve this?

Hrrsmjd commented 2 years ago

were you able to solve this?

No.

rteuwens commented 1 year ago

I recently had a case with the same error. It was resolved after I specified the language after the ``` in one of my code blocks.