chrisjsewell / ipypublish

A workflow for creating and editing publication ready scientific reports and presentations, from one or more Jupyter Notebooks, without leaving the browser!
http://ipypublish.readthedocs.io
BSD 3-Clause "New" or "Revised" License
224 stars 37 forks source link

TypeError: unhashable type: 'Str' when converting ipynb to html or pdf #151

Open frezersa opened 1 year ago

frezersa commented 1 year ago

Bug Report

I was trying to export the example file (https://ipypublish.readthedocs.io/en/latest/_downloads/3aa8aebba17409bb5d3584eaa06bf0e2/Example.ipynb) into html or pdf using nbpublish following the procedure on https://ipypublish.readthedocs.io/en/latest/getting_started.html.

When running command [1]: nbpublish --log-level debug --print-traceback Example.ipynb

First issue: jinja2.exceptions.TemplateNotFound: display_priority.tplx First fix: I changed the display_priority.tplx extension to display_priority.py following https://github.com/daha96/ipypublish/commit/e3c9421dcfee61f278037c1e4022736cdfb01323

Second issue: when trying running command [1] after fixing the first issue, I got (full log error is at the end) File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\filters_pandoc\prepare_labels.py", line 157, in if el not in to_delete TypeError: unhashable type: 'Str'

To Reproduce

Steps to reproduce the behavior:

  1. changed the display_priority.tplx extension to display_priority.py

Minimal Notebook Example

I used the file https://ipypublish.readthedocs.io/en/latest/_downloads/3aa8aebba17409bb5d3584eaa06bf0e2/Example.ipynb

Expected Behaviour

Convert ipynb to html or preferably pdf with figure and table captions.

Runtime Information

Logging

(ipyreport) C:\Users\4977988\OneDrive\Clim_Analysis\test>nbpublish --log-level debug --print-traceback Example.ipynb INFO:ipypublish:started ipypublish v0.10.12 at Fri Feb 24 15:36:20 2023 INFO:ipypublish:logging to: C:\Users\4977988\OneDrive\Clim_Analysis\test\converted\Example.nbpub.log INFO:ipypublish:running for ipynb(s) at: Example.ipynb INFO:ipypublish:with conversion configuration: latex_ipypublish_main INFO:nbmerge:Reading notebook DEBUG:ipypublish:notebooks meta path: Example.ipynb INFO:ipypublish:finding conversion configuration: latex_ipypublish_main INFO:ipypublish:loading conversion configuration INFO:ipypublish:creating exporter INFO:ipypublish:creating template and loading filters DEBUG:template:overwrite keys: [] DEBUG:template:overwrite keys: [] DEBUG:template:overwrite keys: [] DEBUG:template:overwrite keys: [] DEBUG:template:overwrite keys: [] DEBUG:template:overwrite keys: [] DEBUG:template:overwrite keys: [] DEBUG:template:overwrite keys: [] INFO:ipypublish:creating process configuration INFO:ipypublish:running nbconvert DEBUG:traitlets:Template paths: C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\latex C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\base C:\Anaconda33\envs\ipyreport\share\jupyter C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\compatibility C:\Users\4977988\AppData\Roaming\jupyter C:\Users\4977988\AppData\Roaming\jupyter\nbconvert\templates C:\Users\4977988\AppData\Roaming\jupyter\nbconvert\templates\compatibility C:\Users\4977988\AppData\Roaming\Python\share\jupyter C:\Users\4977988\AppData\Roaming\Python\share\jupyter\nbconvert\templates C:\Users\4977988\AppData\Roaming\Python\share\jupyter\nbconvert\templates\compatibility C:\ProgramData\jupyter C:\ProgramData\jupyter\nbconvert\templates C:\ProgramData\jupyter\nbconvert\templates\compatibility C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates DEBUG:traitlets:Applying preprocessor: TagRemovePreprocessor DEBUG:traitlets:Applying preprocessor: RegexRemovePreprocessor DEBUG:traitlets:Applying preprocessor: coalesce_streams DEBUG:traitlets:Applying preprocessor: SVG2PDFPreprocessor DEBUG:traitlets:Applying preprocessor: LatexPreprocessor DEBUG:traitlets:Applying preprocessor: HighlightMagicsPreprocessor DEBUG:traitlets:Applying preprocessor: ExtractOutputPreprocessor DEBUG:traitlets:Applying preprocessor: SplitOutputs INFO:root:splitting outputs into separate cells DEBUG:traitlets:Applying preprocessor: LatexDocLinks INFO:resolve_links:resolving external file paths in ipub metadata to: Example.ipynb WARNING:resolve_links:referenced file(s) do not exist: ['C:\Users\4977988\OneDrive\Clim_Analysis\bibliographies\example.bib', 'C:\Users\4977988\OneDrive\Clim_Analysis\logos\logo_example.png'] DEBUG:traitlets:Applying preprocessor: LatexCaptions INFO:captions:extracting caption cells DEBUG:captions:replacing caption for: code:example_mpl DEBUG:captions:replacing caption for: fig:example_mpl DEBUG:captions:replacing caption for: fig:example_mpl DEBUG:captions:replacing caption for: code:example_pd DEBUG:traitlets:Attempting to load template template_file DEBUG:traitlets: template_paths: C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\latex;C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\base;C:\Anaconda33\envs\ipyreport\share\jupyter;C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates;C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\compatibility;C:\Users\4977988\AppData\Roaming\jupyter;C:\Users\4977988\AppData\Roaming\jupyter\nbconvert\templates;C:\Users\4977988\AppData\Roaming\jupyter\nbconvert\templates\compatibility;C:\Users\4977988\AppData\Roaming\Python\share\jupyter;C:\Users\4977988\AppData\Roaming\Python\share\jupyter\nbconvert\templates;C:\Users\4977988\AppData\Roaming\Python\share\jupyter\nbconvert\templates\compatibility;C:\ProgramData\jupyter;C:\ProgramData\jupyter\nbconvert\templates;C:\ProgramData\jupyter\nbconvert\templates\compatibility;C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates Run Failed: unhashable type: 'Str' Traceback (most recent call last): File "C:\Anaconda33\envs\ipyreport\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Anaconda33\envs\ipyreport\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Anaconda33\envs\ipyreport\Scripts\nbpublish.exe__main__.py", line 7, in File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\frontend\nbpublish.py", line 100, in run outcode = nbpublish(filepath, options) File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\frontend\nbpublish.py", line 83, in nbpublish publish(ipynb_path) File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\convert\main.py", line 354, in call return self.publish(ipynb_path, nb_node) File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\convert\main.py", line 486, in publish exporter, stream, resources = self.export_notebook( File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\convert\main.py", line 615, in export_notebook body, resources = exporter.from_notebook_node(final_nb) File "C:\Anaconda33\envs\ipyreport\lib\site-packages\nbconvert\exporters\latex.py", line 76, in from_notebook_node return super().from_notebook_node(nb, resources, kw) File "C:\Anaconda33\envs\ipyreport\lib\site-packages\nbconvert\exporters\templateexporter.py", line 421, in from_notebook_node output = self.template.render(nb=nb_copy, resources=resources) File "C:\Anaconda33\envs\ipyreport\lib\site-packages\jinja2\environment.py", line 1301, in render self.environment.handle_exception() File "C:\Anaconda33\envs\ipyreport\lib\site-packages\jinja2\environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "