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: module 'mistune' has no attribute 'BlockGrammar' #6531

Closed
Davidy22 opened this issue Sep 1, 2022 · 6 comments
Closed

AttributeError: module 'mistune' has no attribute 'BlockGrammar' #6531

Davidy22 opened this issue Sep 1, 2022 · 6 comments
Labels

Comments

@Davidy22
Copy link

Davidy22 commented Sep 1, 2022

Describe the bug
There is an error, "AttributeError: module 'mistune' has no attribute 'BlockGrammar'", caused by the mistune library changing their whole structure and the intermediate dependency m2r not being updated or pinning deps. There is a library m2r2 that aims to be maintained and fix that issue because m2r appears to be unresponsive, and switching to that I believe should resolve the issue.

To Reproduce
Steps to reproduce the behavior:

  1. Try to open a notebook

Expected behavior
Notebook opens

Desktop (please complete the following information):

  • OS: Fedora 36
  • Browser agnostic

23:13:50❯ jupyter --version
Selected Jupyter core packages...
IPython : 8.4.0
ipykernel : 6.15.0
ipywidgets : 7.7.1
jupyter_client : 7.3.4
jupyter_core : 4.10.0
jupyter_server : not installed
jupyterlab : not installed
nbclient : 0.6.6
nbconvert : 6.5.0
nbformat : 5.4.0
notebook : 6.4.12
qtconsole : 5.3.1
traitlets : 5.3.0

@Davidy22 Davidy22 added the bug label Sep 1, 2022
@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to issues that need triage label Sep 1, 2022
@RRosio
Copy link
Collaborator

RRosio commented Sep 1, 2022

Hi @Davidy22 thank you for submitting this issue. We found this issue in nbconvert that seems to be related. It seems like in nbconvert version 7.0.0 this may be fixed, but I'm tagging @blink1073 in case Steve can provide more information.

@RRosio RRosio removed the status:Needs Triage Applied to issues that need triage label Sep 1, 2022
@blink1073
Copy link
Contributor

I believe this is related to sphinx-contrib/openapi#123. We don't use mr2 directly in any Jupyter libraries as far as I know, but if it is pulled in by a dependency, then you need to add mistune<1 to your requirements file, or manually install that version.

@grisaitis
Copy link

grisaitis commented Sep 2, 2022

It seems like in nbconvert version 7.0.0 this may be fixed, but I'm tagging @blink1073 in case Steve can provide more information.

I'm experiencing this with nbconvert 7.0.0 :/

❯ conda list | grep nbconvert
nbconvert                 7.0.0                    pypi_0    pypi
❯ conda list | grep mistune
mistune                   2.0.4                    pypi_0    pypi
`conda env export`

name: base channels: - conda-forge dependencies: - aiohttp=3.8.1=py39hb18efdd_1 - aiosignal=1.2.0=pyhd8ed1ab_0 - alabaster=0.7.12=py_0 - anyio=3.6.1=pyhd8ed1ab_1 - appnope=0.1.3=pyhd8ed1ab_0 - argon2-cffi=21.3.0=pyhd8ed1ab_0 - argon2-cffi-bindings=21.2.0=py39hb18efdd_2 - astroid=2.11.6=py39h2804cbe_0 - asttokens=2.0.8=pyhd8ed1ab_0 - async-timeout=4.0.2=pyhd8ed1ab_0 - autopep8=1.6.0=pyhd8ed1ab_1 - babel=2.10.3=pyhd8ed1ab_0 - backcall=0.2.0=pyh9f0ad1d_0 - backports=1.0=py_2 - backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0 - beautifulsoup4=4.11.1=pyha770c72_0 - black=22.6.0=pyhd8ed1ab_0 - black-jupyter=22.6.0=hd8ed1ab_2 - bleach=5.0.1=pyhd8ed1ab_0 - brotlipy=0.7.0=py39h5161555_1003 - bzip2=1.0.8=h3422bc3_4 - c-ares=1.18.1=h3422bc3_0 - ca-certificates=2022.6.15=h4653dfc_0 - certifi=2022.6.15=pyhd8ed1ab_1 - cffi=1.15.0=py39h52b1de0_0 - charset-normalizer=2.0.12=pyhd8ed1ab_0 - click=8.1.3=py39h2804cbe_0 - click-completion=0.5.0=py_1 - click-log=0.4.0=pyhd8ed1ab_0 - colorama=0.4.4=pyh9f0ad1d_0 - conda=4.14.0=py39h2804cbe_0 - conda-package-handling=1.8.0=py39hb18efdd_0 - cryptography=36.0.2=py39hbe5e4b8_0 - dataclasses=0.8=pyhc8e2a94_3 - debugpy=1.6.3=py39h3c22d25_0 - decorator=5.1.1=pyhd8ed1ab_0 - defusedxml=0.7.1=pyhd8ed1ab_0 - dill=0.3.5.1=pyhd8ed1ab_0 - entrypoints=0.4=pyhd8ed1ab_0 - executing=1.0.0=pyhd8ed1ab_0 - flake8=4.0.1=pyhd8ed1ab_2 - flit=3.7.1=pyhd8ed1ab_0 - flit-core=3.7.1=pyhd8ed1ab_0 - frozenlist=1.3.1=py39h4eb3d34_0 - gitdb=4.0.9=pyhd8ed1ab_0 - gitpython=3.1.27=pyhd8ed1ab_0 - greenlet=1.1.3=py39h23fbdae_0 - icu=70.1=h6b3803e_0 - idna=3.3=pyhd8ed1ab_0 - imagesize=1.4.1=pyhd8ed1ab_0 - importlib_metadata=4.11.4=hd8ed1ab_0 - importlib_resources=5.9.0=pyhd8ed1ab_0 - ipykernel=6.15.2=pyh736e0ef_0 - ipython=8.4.0=pyhd1c38e8_1 - ipython_genutils=0.2.0=py_1 - ipywidgets=7.6.5=pyhd8ed1ab_0 - isort=5.10.1=pyhd8ed1ab_0 - jedi=0.18.1=pyhd8ed1ab_2 - jinja2=3.1.2=pyhd8ed1ab_1 - jupyter=1.0.0=py39h2804cbe_7 - jupyter-book=0.13.1=pyhd8ed1ab_0 - jupyter-lsp=1.5.1=pyhd8ed1ab_0 - jupyter-server-mathjax=0.2.6=pyhc268e32_0 - jupyter-server-proxy=3.2.1=pyhd8ed1ab_0 - jupyter-sphinx=0.3.2=pyhd8ed1ab_1 - jupyter_client=7.3.5=pyhd8ed1ab_0 - jupyter_console=6.4.4=pyhd8ed1ab_0 - jupyter_core=4.11.1=py39h2804cbe_0 - jupyter_server=1.16.0=pyhd8ed1ab_0 - jupyterlab=3.4.5=pyhd8ed1ab_0 - jupyterlab-git=0.39.1=pyhd8ed1ab_0 - jupyterlab-lsp=3.10.2=pyhd8ed1ab_0 - jupyterlab_code_formatter=1.5.3=pyhd8ed1ab_0 - jupyterlab_miami_nights=0.3.2=pyhd8ed1ab_0 - jupyterlab_pygments=0.2.2=pyhd8ed1ab_0 - jupyterlab_server=2.15.1=pyhd8ed1ab_0 - jupyterlab_widgets=3.0.2=pyhd8ed1ab_0 - krb5=1.19.3=hf9b2bbe_0 - latexcodec=2.0.1=pyh9f0ad1d_0 - lazy-object-proxy=1.7.1=py39hb18efdd_1 - libarchive=3.5.2=h69ec738_2 - libcurl=7.83.1=h2fcd78c_0 - libcxx=14.0.6=h2692d47_0 - libedit=3.1.20191231=hc8eb9b7_2 - libev=4.33=h642e427_1 - libffi=3.4.2=h3422bc3_5 - libiconv=1.16=h642e427_0 - libmamba=0.25.0=h65ddd87_2 - libmambapy=0.25.0=py39hd1b7750_2 - libnghttp2=1.47.0=he723fca_0 - libsodium=1.0.18=h27ca646_1 - libsolv=0.7.22=h1280f1d_0 - libssh2=1.10.0=hb80f160_2 - libxml2=2.9.14=h035c1df_0 - libzlib=1.2.11=hee7b306_1013 - linkify-it-py=1.0.3=pyhd8ed1ab_0 - lz4-c=1.9.3=hbdafb3b_1 - lzo=2.10=h642e427_1000 - mamba=0.25.0=py39hde45b87_2 - markupsafe=2.1.1=py39hb18efdd_1 - matplotlib-inline=0.1.6=pyhd8ed1ab_0 - mccabe=0.6.1=py_1 - multidict=6.0.2=py39hb18efdd_1 - mypy_extensions=0.4.3=py39h2804cbe_5 - nb_conda_kernels=2.3.1=py39h2804cbe_1 - nbclient=0.5.13=pyhd8ed1ab_0 - nbdime=3.1.1=pyhd8ed1ab_0 - nbformat=5.4.0=pyhd8ed1ab_0 - nbqa=1.4.0=pyhd8ed1ab_0 - ncurses=6.3=hc470f4d_0 - nest-asyncio=1.5.5=pyhd8ed1ab_0 - notebook=6.4.12=pyha770c72_0 - notebook-shim=0.1.0=pyhd8ed1ab_0 - openssl=1.1.1q=ha287fd2_0 - packaging=21.3=pyhd8ed1ab_0 - pandocfilters=1.5.0=pyhd8ed1ab_0 - parso=0.8.3=pyhd8ed1ab_0 - pathspec=0.10.0=pyhd8ed1ab_0 - pexpect=4.8.0=pyh9f0ad1d_2 - pickleshare=0.7.5=py_1003 - pip=22.2.2=pyhd8ed1ab_0 - platformdirs=2.5.2=pyhd8ed1ab_1 - plotly=5.10.0=pyhd8ed1ab_0 - pluggy=1.0.0=py39h2804cbe_3 - prometheus_client=0.14.1=pyhd8ed1ab_0 - prompt_toolkit=3.0.30=hd8ed1ab_0 - psutil=5.9.1=py39h9eb174b_0 - ptyprocess=0.7.0=pyhd3deb0d_0 - pure_eval=0.2.2=pyhd8ed1ab_0 - pybind11-abi=4=hd8ed1ab_3 - pybtex=0.24.0=pyhd8ed1ab_2 - pybtex-docutils=1.0.2=py39h2804cbe_1 - pycodestyle=2.8.0=pyhd8ed1ab_0 - pycosat=0.6.3=py39h5161555_1009 - pycparser=2.21=pyhd8ed1ab_0 - pydata-sphinx-theme=0.8.1=pyhd8ed1ab_0 - pydocstyle=6.1.1=pyhd8ed1ab_0 - pyflakes=2.4.0=pyhd8ed1ab_0 - pygments=2.13.0=pyhd8ed1ab_0 - pylint=2.14.4=pyhd8ed1ab_0 - pyopenssl=22.0.0=pyhd8ed1ab_0 - pyparsing=3.0.9=pyhd8ed1ab_0 - pyrsistent=0.18.1=py39hb18efdd_1 - pysocks=1.7.1=py39h2804cbe_4 - python=3.9.10=hd16f9c5_2_cpython - python-dateutil=2.8.2=pyhd8ed1ab_0 - python-fastjsonschema=2.16.1=pyhd8ed1ab_0 - python-lsp-jsonrpc=1.0.0=pyhd8ed1ab_0 - python-lsp-server=1.5.0=pyhd8ed1ab_0 - python_abi=3.9=2_cp39 - pytoolconfig=1.2.2=pyhd8ed1ab_0 - pytz=2022.2.1=pyhd8ed1ab_0 - pyupgrade=2.37.3=pyhd8ed1ab_0 - pyyaml=6.0=py39hb18efdd_4 - pyzmq=23.2.1=py39h59d144a_0 - readline=8.1.2=h46ed386_0 - reproc=14.2.3=h3422bc3_0 - reproc-cpp=14.2.3=hbdafb3b_0 - requests=2.27.1=pyhd8ed1ab_0 - rope=1.3.0=pyhd8ed1ab_0 - ruamel_yaml=0.15.80=py39h5161555_1006 - send2trash=1.8.0=pyhd8ed1ab_0 - setuptools=60.10.0=py39h2804cbe_0 - shellingham=1.5.0=pyhd8ed1ab_0 - simpervisor=0.4=pyhd8ed1ab_0 - six=1.16.0=pyh6c4a22f_0 - smmap=3.0.5=pyh44b312d_0 - sniffio=1.3.0=pyhd8ed1ab_0 - snowballstemmer=2.2.0=pyhd8ed1ab_0 - soupsieve=2.3.2.post1=pyhd8ed1ab_0 - sphinx-book-theme=0.3.3=pyhd8ed1ab_0 - sphinx-comments=0.0.3=pyh9f0ad1d_0 - sphinx-copybutton=0.5.0=pyhd8ed1ab_0 - sphinx-design=0.1.0=pyhd8ed1ab_0 - sphinx-external-toc=0.2.4=pyhd8ed1ab_0 - sphinx-jupyterbook-latex=0.4.6=pyhd8ed1ab_0 - sphinx-multitoc-numbering=0.1.3=pyhd8ed1ab_0 - sphinx-thebe=0.1.2=pyhd8ed1ab_0 - sphinxcontrib-applehelp=1.0.2=py_0 - sphinxcontrib-bibtex=2.5.0=pyhd8ed1ab_0 - sphinxcontrib-devhelp=1.0.2=py_0 - sphinxcontrib-htmlhelp=2.0.0=pyhd8ed1ab_0 - sphinxcontrib-jsmath=1.0.1=py_0 - sphinxcontrib-qthelp=1.0.3=py_0 - sphinxcontrib-serializinghtml=1.1.5=pyhd8ed1ab_2 - sqlalchemy=1.4.40=py39h4eb3d34_0 - sqlite=3.37.1=h7e3ccbd_0 - stack_data=0.5.0=pyhd8ed1ab_0 - tenacity=8.0.1=pyhd8ed1ab_0 - terminado=0.15.0=py39h2804cbe_0 - testpath=0.6.0=pyhd8ed1ab_0 - tk=8.6.12=he1e0b03_0 - tokenize-rt=4.2.1=pyhd8ed1ab_0 - toml=0.10.2=pyhd8ed1ab_0 - tomli=2.0.1=pyhd8ed1ab_0 - tomli-w=1.0.0=pyhd8ed1ab_0 - tomlkit=0.11.4=pyha770c72_0 - toolz=0.12.0=pyhd8ed1ab_0 - tornado=6.2=py39h9eb174b_0 - tqdm=4.63.0=pyhd8ed1ab_0 - traitlets=5.3.0=pyhd8ed1ab_0 - typed-ast=1.5.4=py39h9eb174b_0 - typing=3.10.0.0=pyhd8ed1ab_0 - typing-extensions=4.3.0=hd8ed1ab_0 - typing_extensions=4.3.0=pyha770c72_0 - tzdata=2022a=h191b570_0 - uc-micro-py=1.0.1=pyhd8ed1ab_0 - ujson=5.4.0=py39h6e3512e_0 - urllib3=1.26.9=pyhd8ed1ab_0 - wcwidth=0.2.5=pyh9f0ad1d_2 - websocket-client=1.4.0=pyhd8ed1ab_0 - whatthepatch=1.0.2=pyhd8ed1ab_0 - wheel=0.37.1=pyhd8ed1ab_0 - widgetsnbextension=3.5.2=py39h2804cbe_1 - wrapt=1.14.1=py39h9eb174b_0 - xz=5.2.5=h642e427_1 - yaml=0.2.5=h3422bc3_2 - yaml-cpp=0.7.0=h9a09cb3_1 - yapf=0.32.0=pyhd8ed1ab_0 - zeromq=4.3.4=hbdafb3b_1 - zipp=3.8.1=pyhd8ed1ab_0 - zlib=1.2.11=hee7b306_1013 - zstd=1.5.2=hd705a24_1 - pip: - attrs==22.1.0 - docutils==0.18.1 - importlib-metadata==4.12.0 - ipython-genutils==0.2.0 - json5==0.9.10 - jsonschema==4.15.0 - jupyter-cache==0.5.0 - jupyter-http-server==0.0.1 - jupyter-server==1.18.1 - jupyterlab-markup==1.1.0 - jupyterlab-myst==0.1.6 - lxml==4.9.1 - markdown-it-py==2.1.0 - mdit-py-plugins==0.3.0 - mdurl==0.1.2 - mistune==2.0.4 - myst-nb==0.16.0 - myst-parser==0.18.0 - nbclassic==0.4.3 - nbconvert==7.0.0 - prompt-toolkit==3.0.31 - sphinx==5.1.1 - sphinx-togglebutton==0.3.2 - tabulate==0.8.10 - tinycss2==1.1.1 - webencodings==0.5.1 - yarl==1.8.1 prefix: /Users/william/.pyenv/versions/miniforge3

@Davidy22
Copy link
Author

Davidy22 commented Sep 4, 2022

Yeah, it's an intermediate dependency. I was already able to get opening notebooks to work by downgrading mistune but there'll probably be other people impacted by the cascading dependency issues flowing from m2r. Actually, I can grab the stack trace when mistune is the latest version:

    Traceback (most recent call last):
      File "/home/davidos/.local/lib/python3.10/site-packages/tornado/web.py", line 1713, in _execute
        result = await result
      File "/home/davidos/.local/lib/python3.10/site-packages/tornado/gen.py", line 782, in run
        yielded = self.gen.send(value)
      File "/home/davidos/.local/lib/python3.10/site-packages/notebook/notebook/handlers.py", line 94, in get
        self.write(self.render_template('notebook.html',
      File "/home/davidos/.local/lib/python3.10/site-packages/notebook/base/handlers.py", line 511, in render_template
        return template.render(**ns)
      File "/home/davidos/.local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
        self.environment.handle_exception()
      File "/home/davidos/.local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "/home/davidos/.local/lib/python3.10/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/home/davidos/.local/lib/python3.10/site-packages/notebook/templates/page.html", line 154, in top-level template code
        {% block header %}
      File "/home/davidos/.local/lib/python3.10/site-packages/notebook/templates/notebook.html", line 115, in block 'header'
        {% for exporter in get_frontend_exporters() %}
      File "/home/davidos/.local/lib/python3.10/site-packages/notebook/notebook/handlers.py", line 23, in get_frontend_exporters
        from nbconvert.exporters.base import get_export_names, get_exporter
      File "/home/davidos/.local/lib/python3.10/site-packages/nbconvert/__init__.py", line 3, in <module>
        from . import filters, postprocessors, preprocessors, writers
      File "/home/davidos/.local/lib/python3.10/site-packages/nbconvert/filters/__init__.py", line 8, in <module>
        from .markdown import *
      File "/home/davidos/.local/lib/python3.10/site-packages/nbconvert/filters/markdown.py", line 13, in <module>
        from .markdown_mistune import markdown2html_mistune
      File "/home/davidos/.local/lib/python3.10/site-packages/nbconvert/filters/markdown_mistune.py", line 37, in <module>
        class MathBlockGrammar(mistune.BlockGrammar):
    AttributeError: module 'mistune' has no attribute 'BlockGrammar'

I don't remember why I pointed the finger at m2r, but it seems like the last offending dependency before the invalid usage of the overhauled mistune is nbconvert. Looks like another jupyter repo, is there a way to move an issue or should I recreate or is this issue here sufficient?

@blink1073
Copy link
Contributor

Pinning mistune will work in all cases, but the issue in nbconvert has already been fixed through the 7.0 release. jupyter/nbconvert#1842

@Davidy22
Copy link
Author

Davidy22 commented Sep 5, 2022

Oh, I guess that makes this issue moot then. How'd my pip jupyter install give me nbconvert 6.5? Well, shouldn't be an issue going forward for new installs then I think.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants