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

AttributeError: 'MathBlockParser' object has no attribute 'parse_axt_heading' #403

Closed
falexwolf opened this issue Dec 30, 2024 · 12 comments · Fixed by tradingstrategy-ai/trade-executor#1124

Comments

@falexwolf
Copy link

Thank you for the great package!

Just since 3.1.0, I'm getting these errors, which were absent in all previous versions:

E           File /opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/site-packages/nbconvert/filters/markdown_mistune.py:471, in MarkdownWithMath.__init__(self, renderer, block, inline, plugins)
E               469 """Initialize the parser."""
E               470 if block is None:
E           --> 471     block = MathBlockParser()
E               472 if inline is None:
E               473     if MISTUNE_V3:
E           
E           File /opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/site-packages/mistune/block_parser.py:111, in BlockParser.__init__(self, block_quote_rules, list_rules, max_nested_level)
E               108 self.max_nested_level = max_nested_level
E               109 # register default parse methods
E               110 self._methods = {
E           --> 111     name: getattr(self,'parse_'+name) for name in self.SPECIFICATION
E               112 }
E           
E           AttributeError: 'MathBlockParser' object has no attribute 'parse_axt_heading'
@TLCFEM
Copy link

TLCFEM commented Dec 30, 2024

Something seems to be broken with the new version.

See also:

https://github.com/TLCFEM/suanPan-manual/actions/runs/12541734617/job/34970864627

@serena-ruan
Copy link

+1, encountering this same issue by running command

jupyter nbconvert --to html --execute notebooks/jupyter.ipynb

Traceback

[NbConvertApp] Converting notebook notebooks/jupyter.ipynb to html
Traceback (most recent call last):
  File "/home/circleci/.pyenv/versions/3.9.21/bin/jupyter-nbconvert", line 8, in <module>
    sys.exit(main())
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/jupyter_core/application.py", line 283, in launch_instance
    super().launch_instance(argv=argv, **kwargs)
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/traitlets/config/application.py", line 1075, in launch_instance
    app.start()
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 420, in start
    self.convert_notebooks()
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 597, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 563, in convert_single_notebook
    output, resources = self.export_single_notebook(
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 487, in export_single_notebook
    output, resources = self.exporter.from_filename(
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 386, in from_filename
    return super().from_filename(filename, resources, **kw)  # type:ignore[return-value]
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 201, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 392, in from_file
    return super().from_file(file_stream, resources, **kw)  # type:ignore[return-value]
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/exporters/exporter.py", line 220, in from_file
    return self.from_notebook_node(
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/exporters/html.py", line 268, in from_notebook_node
    html, resources = super().from_notebook_node(nb, resources, **kw)
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/exporters/templateexporter.py", line 424, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/jinja2/environment.py", line 1295, in render
    self.environment.handle_exception()
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/jinja2/environment.py", line 942, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/lab/index.html.j2", line 4, in top-level template code
    {% from 'jupyter_widgets.html.j2' import jupyter_widgets %}
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/lab/base.html.j2", line 3, in top-level template code
    {% from 'cell_id_anchor.j2' import cell_id_anchor %}
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code
    {%- extends 'base/null.j2' -%}
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
    {%- block body -%}
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/base/null.j2", line 29, in block 'body'
    {%- block body_loop -%}
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/base/null.j2", line 31, in block 'body_loop'
    {%- block any_cell scoped -%}
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/base/null.j2", line 87, in block 'any_cell'
    {%- block markdowncell scoped-%} {%- endblock markdowncell -%}
  File "/home/circleci/.pyenv/versions/3.9.21/share/jupyter/nbconvert/templates/lab/base.html.j2", line 109, in block 'markdowncell'
    {%- set html_value=cell.source  | markdown2html | strip_files_prefix -%}
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/exporters/html.py", line 243, in markdown2html
    return MarkdownWithMath(renderer=renderer).render(source)
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/nbconvert/filters/markdown_mistune.py", line 471, in __init__
    block = MathBlockParser()
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/mistune/block_parser.py", line 110, in __init__
    self._methods = {
  File "/home/circleci/.pyenv/versions/3.9.21/lib/python3.9/site-packages/mistune/block_parser.py", line 111, in <dictcomp>
    name: getattr(self, 'parse_' + name) for name in self.SPECIFICATION
AttributeError: 'MathBlockParser' object has no attribute 'parse_axt_heading'

@fcollonval
Copy link

This can be closed as the issue is in the upstream package nbconvert.

Xref jupyter/nbconvert#2198

@glenn-jocher
Copy link

nbconvert has not changed recently but about 10 hours ago we started seeing errors in the new mistune package:
https://github.com/ultralytics/ultralytics/actions/runs/12542947587/job/34973390277

@mfisher87
Copy link

mfisher87 commented Dec 30, 2024

The motiviation behind this change is to correct a typo/spelling mistake (#359). The header style is correctly spelled "atx" because it originated in Aaron Schwartz' atx format.

This can be closed as the issue is in the upstream package nbconvert.

Does this project use semantic versioning? The public API has been broken with this change, so I don't think this issue should be closed. There was more than 1 year since the breaking change was merged and this release, so I think this project does follow semver and unintentionally released this as a minor bump? Just guessing 😁

pstjohn added a commit to NVIDIA/bionemo-framework that referenced this issue Dec 30, 2024
Pins mistune to fix a jupyter notebook build issue introduced in 3.1.0

lepture/mistune#403

Bypassing review rules to fix CI due to holiday OOO
@chenmoneygithub
Copy link

Same issue for DSPy, I am pinning the mistune version for now: stanfordnlp/dspy#2000

@miohtama
Copy link

miohtama commented Jan 1, 2025

If you are hit by this, and novice Python developer, the quick workaround is to pin to the earlier version:

# AttributeError: 'MathBlockParser' object has no attribute 'parse_axt_heading'
# https://github.com/jupyter/nbconvert/issues/2198
mistune = "<3.1"

miohtama added a commit to tradingstrategy-ai/trade-executor that referenced this issue Jan 1, 2025
- Add `correct-accounts` CLI command for Velvet
- Factor `SyncModel` a bit because Velvet vaults are identified by portfolio address, not vault address
- Bump `pyramid-openapi3` to the latest
- Fix lepture/mistune#403
nvdreidenbach pushed a commit to nvdreidenbach/bionemo-framework that referenced this issue Jan 2, 2025
Pins mistune to fix a jupyter notebook build issue introduced in 3.1.0

lepture/mistune#403

Bypassing review rules to fix CI due to holiday OOO

Signed-off-by: Danny <[email protected]>
nvdreidenbach pushed a commit to nvdreidenbach/bionemo-framework that referenced this issue Jan 2, 2025
Pins mistune to fix a jupyter notebook build issue introduced in 3.1.0

lepture/mistune#403

Bypassing review rules to fix CI due to holiday OOO

Signed-off-by: Danny <[email protected]>
nvdreidenbach pushed a commit to nvdreidenbach/bionemo-framework that referenced this issue Jan 2, 2025
Pins mistune to fix a jupyter notebook build issue introduced in 3.1.0

lepture/mistune#403

Bypassing review rules to fix CI due to holiday OOO

Signed-off-by: Danny <[email protected]>
nvdreidenbach pushed a commit to nvdreidenbach/bionemo-framework that referenced this issue Jan 2, 2025
Pins mistune to fix a jupyter notebook build issue introduced in 3.1.0

lepture/mistune#403

Bypassing review rules to fix CI due to holiday OOO

Signed-off-by: Danny <[email protected]>
bob-beck pushed a commit to openbsd/ports that referenced this issue Jan 3, 2025
@lepture
Copy link
Owner

lepture commented Jan 5, 2025

Please lock your version to 3.0

@fcollonval
Copy link

a new version of nbconvert with a fix has been published: https://github.com/jupyter/nbconvert/releases/tag/v7.16.5

This can be closed @lepture.

@gaspardc-met
Copy link

I'm sorry @fcollonval but I tried on my projects and it's still not working.

Setting mistune<=3.1.0 solved the issues, but replacing this with nbconvert>=7.16.5 did not solve the issue for now 😓

Probably doing something wrong, I'll check again

@fcollonval
Copy link

@gaspardc-met could you provide the error you are seeing when using mistune 3.1.0 with nbconvert 7.16.5?

@gaspardc-met
Copy link

@fcollonval : my bad, I did check again and the nbconvert version in the CI wasn't 7.16.5

Thanks for the fix 😉

@lepture lepture closed this as completed Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants