Python Forum
How to edit jupyter nbconvert templates
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to edit jupyter nbconvert templates
#1
I'm currently trying to change the looks of the nbconvert-output in jupyter. To be more precise, I want to convert a ipynb to latex but not using the default tamplate. The thing is I don't know how to edit the files to get the result I want.

Lets say i want to use the "style_notebook.tplx" so I need to download "ipython_nbconvert_config.py" and "use_cell_style.tplx". After that I need to change in the "use_cell_style"-file the second line to "((* set cell_style = 'style_notebook.tplx' *))". But to be honest I don't knwo with what to edit a .tplx File (just used Editor on Windows)...

After changing that and moving the two files to the same directonary as my .ipynb is, I tried the follwoing in the command prompt:

jupyter nbconvert --config ipython_nbconvert_config filename.ipynb --to latex
and got the error:

[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'
So it says that I miss the PDF-module, but I'm not sure hows that possible, because until now I could convert to pdf just fine. So I aussume I made some mistakes in changing the files...

Would be nice if someone could explain how to fix this problem..

Thanks, Sito.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  nbconvert Jupyter to LaTeX ross1993hall 3 2,791 Jul-13-2020, 09:11 AM
Last Post: ross1993hall
  Error executing Jupyter command 'notebook': [Errno 'jupyter-notebook' not found] 2 Newtopython123 10 31,377 Apr-25-2019, 07:30 AM
Last Post: banu0395

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020