AttributeError: Module ‘mistune’ Has No Attribute ‘BlockGrammar’

I was installing some dependency requirements for my project on a Windows machine by running the below command.

py -m pip install -r requirements.txt

And I got the below error.

Exact Error Message: “Preparing metadata ( … error
  error: subprocess-exited-with-error
  × python egg_info did not run successfully.
  ¦ exit code: 1
  ?-> [8 lines of output]
      Traceback (most recent call last):
        File “<string>”, line 2, in <module>
        File “<pip-setuptools-caller>”, line 34, in <module>
        File “C:\Users\rijsat\AppData\Local\Temp\pip-install-zuk43gtq\m2r_e56fc974548d456482c4df30a3e037e6\”, line 14, in <module>
          from m2r import parse_from_file
        File “C:\Users\rijsat\AppData\Local\Temp\pip-install-zuk43gtq\m2r_e56fc974548d456482c4df30a3e037e6\”, line 59, in <module>
          class RestBlockGrammar(mistune.BlockGrammar):
      AttributeError: module ‘mistune’ has no attribute ‘BlockGrammar’
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
?-> See above for output.

note: This is an issue with the package mentioned above, not pip.

hint: See above for details.”


Then I downgraded the mistune version as suggested here. You can run the below cmd to install the lower working version of the mistune. Once, I downgraded the mistune version, the error got resolved.

py -m pip install mistune==0.8.4

I hope, it will be helpful for you, if you encounter the same issue.