nbconvert: nbconvert AttributeError: module 'mistune' has no attribute 'BlockGrammar'
nbconvert 6.4.4 fails using mistune 2.0.4
Install/update your conda env to those versions (latest) and creating or accessing any notebook fails with this error:
{% for exporter in get_frontend_exporters() %}
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\notebook\handlers.py", line 23, in get_frontend_exporters
from nbconvert.exporters.base import get_export_names, get_exporter
File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\__init__.py", line 4, in <module>
from .exporters import *
File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\__init__.py", line 3, in <module>
from .html import HTMLExporter
File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\html.py", line 25, in <module>
from nbconvert.filters.highlight import Highlight2HTML
File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\filters\__init__.py", line 6, in <module>
from .markdown import *
File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\filters\markdown.py", line 13, in <module>
from .markdown_mistune import markdown2html_mistune
File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\filters\markdown_mistune.py", line 40, in <module>
class MathBlockGrammar(mistune.BlockGrammar):
AttributeError: module 'mistune' has no attribute 'BlockGrammar'
Nbconvert version: 6.4.4
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 15 (3 by maintainers)
The 7.x line imports
BlockParser
, notBlockGrammar
.Please ensure you have installed the correct versions.
Modifying for your environment management approach, in the case of
pip
:Or
conda
.Reinstall nbconvert==7.2.1 with pip and
Found existing installation: nbconvert 6.4.4
😥 Now everything works fine. But it is still weird because I setup the environment from a clean conda env.I also had this error with: nbconvert==7.2.7 mistune 2.0.4
Solved by downgrading nbconvert to: nbconvert==7.2.1 mistune 2.0.4
Same problem with
nbconvert==7.2.1
andmistune 2.0.4
When
pip list
shows nbconvert version number is 7.2.1, the _version.py file in installed pkg is:Seems like the pkg on pypi is broken?
If you are seeing an
AttributeError
aboutBlockGrammar
that string no longer appears in the pip or conda distributions.You may have multiple, overlapping environments, user paths,
PYTHONPATH
, etc. that would also need to be upgraded.The nbconvert 6.x line is not compatible with mistune >=2. Please upgrade to nbconvert 7.x.