Error in Converting iPython Notebook file to PDF

2019-09-18 20:17发布

问题:

I am using linux and trying to convert .ipynb file to .pdf by following instructions from here

but I am getting following error

ipython nbconvert notebook_file.ipynb --to latex --post PDF but I am getting following error

[NbConvertApp] Using existing profile dir: u'/home/user/.ipython/profile_default'
Traceback (most recent call last):
  File "/usr/bin/ipython", line 5, in <module>
    start_ipython()
  File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 120, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 565, in launch_instance
    app.start()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 367, in start
    return self.subapp.start()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 268, in start
    self.convert_notebooks()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 284, in convert_notebooks
    exporter = exporter_map[self.export_format](config=self.config)
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/templateexporter.py", line 154, in __init__
    self._init_template()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/templateexporter.py", line 272, in _init_template
    self._template_file_changed('template_file', self.template_file, self.template_file)
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/templateexporter.py", line 97, in _template_file_changed
    self._load_template()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/templateexporter.py", line 167, in _load_template
    from jinja2 import TemplateNotFound
ImportError: No module named jinja2

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

then I tried to convert in into default html format using following command

ipython nbconvert notebook_file.ipynb

then I am getting following errors

[NbConvertApp] Using existing profile dir: u'/home/user/.ipython/profile_default'
Traceback (most recent call last):
  File "/usr/bin/ipython", line 5, in <module>
    start_ipython()
  File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 120, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 565, in launch_instance
    app.start()
  File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 367, in start
    return self.subapp.start()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 268, in start
    self.convert_notebooks()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 284, in convert_notebooks
    exporter = exporter_map[self.export_format](config=self.config)
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/templateexporter.py", line 151, in __init__
    super(TemplateExporter, self).__init__(config=config, **kw)
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/exporter.py", line 94, in __init__
    self._init_preprocessors()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/exporter.py", line 222, in _init_preprocessors
    self.register_preprocessor(preprocessor)
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/exporter.py", line 188, in register_preprocessor
    return self.register_preprocessor(preprocessor_cls, enabled)
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/exporters/exporter.py", line 201, in register_preprocessor
    self.register_preprocessor(preprocessor(parent=self), enabled)
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/preprocessors/csshtmlheader.py", line 54, in __init__
    self._regen_header()
  File "/usr/lib/python2.7/dist-packages/IPython/nbconvert/preprocessors/csshtmlheader.py", line 90, in _regen_header
    from IPython.html import DEFAULT_STATIC_FILES_PATH
ImportError: No module named html

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

I have tried all the possible option but all in-vain

Did I miss something???

thanks in advance...