question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot import name 'DocutilsRenderer' from 'myst_parser.docutils_renderer'

See original GitHub issue

Describe the problem

The sphinx build process fails due to an importerror with myst-parser:

# Loaded extensions:
#   sphinx.ext.mathjax (4.2.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinxcontrib\applehelp\__init__.py
#   sphinxcontrib.devhelp (1.0.2) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinxcontrib\devhelp\__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinxcontrib\htmlhelp\__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinxcontrib\serializinghtml\__init__.py
#   sphinxcontrib.qthelp (1.0.3) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinxcontrib\qthelp\__init__.py
#   alabaster (0.7.12) from e:\source\dha-datapype\.dev_env\lib\site-packages\alabaster\__init__.py
#   sphinx.ext.autodoc.preserve_defaults (1.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\autodoc\preserve_defaults.py
#   sphinx.ext.autodoc.type_comment (4.2.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\autodoc\type_comment.py
#   sphinx.ext.autodoc (4.2.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\autodoc\__init__.py
#   sphinx.ext.autosummary (4.2.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\autosummary\__init__.py
#   sphinx.ext.viewcode (4.2.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\viewcode.py
#   sphinx_autodoc_typehints (unknown version) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx_autodoc_typehints.py
#   sphinx.ext.intersphinx (4.2.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\intersphinx.py
#   myst_parser (0.15.2) from e:\source\dha-datapype\.dev_env\lib\site-packages\myst_parser\__init__.py
#   sphinx.ext.todo (4.2.0) from e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\ext\todo.py
Traceback (most recent call last):
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\cmd\build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\application.py", line 343, in build
    self.builder.build_update()
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\builders\__init__.py", line 295, in build_update
    len(to_build))
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\builders\__init__.py", line 307, in build
    updated_docnames = set(self.read())
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\builders\__init__.py", line 414, in read
    self._read_serial(docnames)
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\builders\__init__.py", line 435, in _read_serial
    self.read_doc(docname)
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\builders\__init__.py", line 475, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\io.py", line 189, in read_doc
    pub.publish()
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\docutils\core.py", line 218, in publish
    self.settings)
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\sphinx\io.py", line 109, in read
    self.parse()
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\docutils\readers\__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\myst_parser\sphinx_parser.py", line 53, in parse
    parser = default_parser(config)
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\myst_parser\main.py", line 139, in default_parser
    from myst_parser.sphinx_renderer import SphinxRenderer
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\myst_parser\sphinx_renderer.py", line 26, in <module>
    from myst_parser.docutils_renderer import DocutilsRenderer
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\myst_parser\docutils_renderer.py", line 41, in <module>
    from myst_parser.mocking import (
  File "e:\source\dha-datapype\.dev_env\lib\site-packages\myst_parser\mocking.py", line 21, in <module>
    from .docutils_renderer import DocutilsRenderer
ImportError: cannot import name 'DocutilsRenderer' from 'myst_parser.docutils_renderer' (e:\source\dha-datapype\.dev_env\lib\site-packages\myst_parser\docutils_renderer.py)

Link to your repository or website

No response

Steps to reproduce

  1. make html

The version of Python you’re using

3.7

Your operating system

Windows Server Version 1607 OS Build 14393.4651

Versions of your packages

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisjsewellcommented, Oct 7, 2021

Yeh I feel that is a error/misunderstanding of sphinx_autodoc_typehints: TYPE_CHECKING is not just there to stop expensive imports and should never be turned on at runtime. If they want to do something like this, then they should be using proper static code parsing

0reactions
bouchaetcommented, Oct 7, 2021

Ok, thank you for your help. It is very appreciated. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for myst_parser.mdit_to_docutils.base
[docs]class DocutilsRenderer(RendererProtocol): """A markdown-it-py renderer to populate (in-place) a `docutils.document` AST.
Read more >
ImportError: cannot import name 'Parser' - Stack Overflow
Open parser.py file and change the code for from parser import Parser to from .parser import Parser.
Read more >
A deep dive into MyST, Part 2: The MyST-Parser, Docutils and ...
The DocutilsRenderer converts a token directly to the docutils.document representation of the document, converting roles and directives to a ...
Read more >
myst-parser - PyPI
An extended commonmark compliant parser, with bridges to docutils & sphinx.
Read more >
myst-parser Changelog - PyUp.io
MyST-Parser looks to smartly resolve such links, by identifying if they are: ... IMPROVE: `DocutilsRenderer.create_highlighted_code_block` in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found