Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

Converting jupyter notebook to pdf - nbconvert

I have been able to use nbconvert to convert .ipynb files into pdf in the past, but it isn’t working now. I am using a Windows machine and I have Inkscape installed. This is the error that I am getting:

[NbConvertApp] Converting notebook mlp-week02.ipynb to pdf
Traceback (most recent call last):
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.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:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.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:userss1612415appdatalocalprogramspythonpython39lib
unpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:userss1612415appdatalocalprogramspythonpython39lib
unpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:Userss1612415AppDataLocalProgramsPythonPython39Scriptsjupyter-nbconvert.EXE\__main__.py", line 7, in <module>
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesjupyter_coreapplication.py", line 254, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsconfigapplication.py", line 845, in launch_instance
    app.start()
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvert
bconvertapp.py", line 350, in start
    self.convert_notebooks()
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvert
bconvertapp.py", line 524, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvert
bconvertapp.py", line 489, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvert
bconvertapp.py", line 418, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertexportersexporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertexportersexporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertexporterspdf.py", line 168, in from_notebook_node
    latex, resources = super().from_notebook_node(
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertexporterslatex.py", line 77, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertexportersemplateexporter.py", line 369, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertexportersexporter.py", line 143, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertexportersexporter.py", line 318, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertpreprocessorsase.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertpreprocessorsase.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertpreprocessorsconvertfigures.py", line 45, in preprocess_cell
    output.data[self.to_format] = self.convert_figure(
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertpreprocessorssvg2pdf.py", line 125, in convert_figure
    shell = self.command.format(from_filename=input_filename,
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 1578, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertpreprocessorssvg2pdf.py", line 77, in _command_default
    major_verison = self.inkscape_version.split('.')[0]
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 1578, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packagesraitletsraitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "c:userss1612415appdatalocalprogramspythonpython39libsite-packages
bconvertpreprocessorssvg2pdf.py", line 63, in _inkscape_version_default
    return output.decode('utf-8').split(' ')[1]
IndexError: list index out of range

I am not sure what the error is. Any ideas?

I have been able to use nbconvert to convert .ipynb files into pdf in the past, but it isn’t working now. I am using a Windows machine and I have Inkscape installed. This is the error that I am getting: I am not sure what the error is. Any ideas?

question from:https://stackoverflow.com/questions/65858052/converting-jupyter-notebook-to-pdf-nbconvert

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...