如何修改jupyter nbconvert templates

时间:2017-07-08 14:03:22

标签: python pdf jupyter

我目前正在尝试更改jupyter中nbconvert-output的外观。更确切地说,我想将ipynb转换为latex,但不使用默认的tamplate。问题是我不知道如何编辑文件以获得我想要的结果。

假设我想使用“style_notebook.tplx”,所以我需要下载ipython_nbconvert_config.pyuse_cell_style.tplx。之后,我需要将use_cell_style文件中的第二行更改为((* set cell_style = 'style_notebook.tplx' *))。但说实话,我不知道编辑.tplx文件的内容(我只使用Windows编辑器)....

在更改它并将两个文件移动到与.ipynb相同的直接冠军之后,我在命令提示符下尝试了这个:

jupyter nbconvert --config ipython_nbconvert_config --to latex filename.ipynb

并收到错误:

[NbConvertApp] WARNING | Error loading config file: ipython_nbconvert_config
Traceback (most recent call last):
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\jupyter_core\application.py", line 202, in load_config_file
    path=path
  File "<decorator-gen-5>", line 2, in load_config_file
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\config\application.py", line 603, in load_config_file
    self.update_config(new_config)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\config\configurable.py", line 198, in update_config
    self._load_config(config)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\config\configurable.py", line 168, in _load_config
    warn(msg)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\contextlib.py", line 89, in __exit__
    next(self.gen)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\traitlets.py", line 1131, in hold_trait_notifications
    self.notify_change(change)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\traitlets.py", line 1176, in notify_change
    c(change)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\nbconvert\nbconvertapp.py", line 227, in _postprocessor_class_changed
    self.postprocessor_factory = import_item(new)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\utils\importstring.py", line 42, in import_item
    return __import__(parts[0])
ModuleNotFoundError: No module named 'PDF'
Traceback (most recent call last):
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Sito\AppData\Local\Programs\Python\Python36-32\Scripts\jupyter-nbconvert.EXE\__main__.py", line 9, in <module>
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\config\application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\nbconvert\nbconvertapp.py", line 252, in initialize
    self.init_postprocessor()
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\nbconvert\nbconvertapp.py", line 298, in init_postprocessor
    self._postprocessor_class_changed({'new': self.postprocessor_class})
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\nbconvert\nbconvertapp.py", line 227, in _postprocessor_class_changed
    self.postprocessor_factory = import_item(new)
  File "c:\users\Sito\appdata\local\programs\python\python36-32\lib\site-packages\traitlets\utils\importstring.py", line 42, in import_item
    return __import__(parts[0])
ModuleNotFoundError: No module named 'PDF'

所以它说我错过了PDF模块,但我不确定这可能是什么,因为直到现在我可以转换为pdf就好了。所以我觉得我在更改文件方面犯了一些错误......

如果有人能解释如何解决这个问题会很好。

谢谢,Sito。

0 个答案:

没有答案