Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
frezersa opened this issue Feb 24, 2023 · 0 comments
Open
Labels

Comments

@frezersa
Copy link

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 daha96@e3c9421

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

  • IPyPublish: 0.10.12
  • Python: 3.10.9
  • OS: Window 10
  • Pandoc: 2.19.2
  • MiKTeX 23.1

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 "", line 919, in top-level template code
File "C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\latex\display_priority.j2", line 5, in top-level template code
((- extends 'null.j2' -))
File "C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\latex\null.j2", line 30, in top-level template code
((- block body -))
File "", line 575, in block 'body'
File "C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\latex\null.j2", line 32, in block 'body'
((- block any_cell scoped -))
File "", line 621, in block 'any_cell'
File "C:\Anaconda33\envs\ipyreport\share\jupyter\nbconvert\templates\latex\null.j2", line 85, in block 'any_cell'
((- block markdowncell scoped-)) ((- endblock markdowncell -))
File "", line 651, in block 'markdowncell'
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\filters_pandoc\main.py", line 209, in jinja_filter
out_str = apply_filter(
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\filters_pandoc\utils.py", line 114, in apply_filter
out_doc = func(out_doc, **kwargs) # type: Doc
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\filters_pandoc\prepare_labels.py", line 181, in main
return pf.run_filters(
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\panflute\io.py", line 208, in run_filters
doc = doc.walk(action, doc=doc, stop_if=stop_if)
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\panflute\base.py", line 264, in walk
child = child.walk(action, doc, stop_if)
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\panflute\containers.py", line 86, in walk
ans = list(chain.from_iterable(ans))
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\panflute\containers.py", line 84, in
ans = ((item,) if type(item) is not list else item for item in ans)
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\panflute\containers.py", line 82, in
ans = (item.walk(action, doc, stop_if) for item in self)
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\panflute\base.py", line 272, in walk
altered = action(self, doc)
File "C:\Anaconda33\envs\ipyreport\lib\site-packages\ipypublish\filters_pandoc\prepare_labels.py", line 147, in resolve_equations_images
new_content = [
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'
Drag and drop the log file here, or copy and paste the output from the terminal

@frezersa frezersa added the bug label Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant