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

Regression? ModuleNotFoundError: No module named 'mkdocstrings.handlers.python' #436

Closed
posita opened this issue May 29, 2022 · 3 comments
Closed
Labels
unconfirmed This bug was not reproduced yet

Comments

@posita
Copy link

posita commented May 29, 2022

Despite no related changes to docs, this recently emerged here: https://github.com/posita/numerary/runs/6643470439?check_suite_focus=true#step:4:127

ERROR    -  Error reading page 'numerary.md': No module named 'mkdocstrings.handlers.python'
  Traceback (most recent call last):
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocstrings/handlers/base.py", line 563, in get_handler
      module = importlib.import_module(f"mkdocstrings_handlers.{name}")
    File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
    File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
  ModuleNotFoundError: No module named 'mkdocstrings_handlers'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/home/runner/work/numerary/numerary/.tox/check/bin/mkdocs", line 8, in <module>
      sys.exit(cli())
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
      return self.main(*args, **kwargs)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/click/core.py", line 1055, in main
      rv = self.invoke(ctx)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
      return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
      return ctx.invoke(self.callback, **ctx.params)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/click/core.py", line 760, in invoke
      return __callback(*args, **kwargs)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocs/__main__.py", line 192, in build_command
      build.build(config.load_config(**kwargs), dirty=not clean)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocs/commands/build.py", line 292, in build
      _populate_page(file.page, config, files, dirty)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocs/commands/build.py", line 1[74](https://github.com/posita/numerary/runs/6643470439?check_suite_focus=true#step:4:75), in _populate_page
      page.render(config, files)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocs/structure/pages.py", line 175, in render
      self.content = md.convert(self.markdown)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/markdown/core.py", line 264, in convert
      root = self.parser.parseDocument(self.lines).getroot()
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/markdown/blockparser.py", line 90, in parseDocument
      self.parseChunk(self.root, '\n'.join(lines))
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/markdown/blockparser.py", line 105, in parseChunk
      self.parseBlocks(parent, text.split('\n\n'))
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/markdown/blockparser.py", line 123, in parseBlocks
      if processor.run(parent, blocks) is not False:
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocstrings/extension.py", line 121, in run
      html, handler, data = self._process_block(identifier, block, heading_level)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocstrings/extension.py", line 175, in _process_block
      handler = self._handlers.get_handler(handler_name, handler_config)
    File "/home/runner/work/numerary/numerary/.tox/check/lib/python3.10/site-packages/mkdocstrings/handlers/base.py", line 565, in get_handler
      module = importlib.import_module(f"mkdocstrings.handlers.{name}")
    File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
  ModuleNotFoundError: No module named 'mkdocstrings.handlers.python'
@posita posita added the unconfirmed This bug was not reproduced yet label May 29, 2022
@pawamoy
Copy link
Member

pawamoy commented May 29, 2022

Hmm, did you try starting fresh again? Recreating any virtualenv managed by tox or yourself?
I've seen this kind of issue happen before.

@posita
Copy link
Author

posita commented May 29, 2022

Yup. I can repro with fresh venvs.

This indeed appears to be a regression (of sorts), as rerunning prior succeeding builds now fails on the same error. I have been able to correct this by changing the appropriate dependency of mkdocstrings to mkdocstrings[python]. I suspect this is related to #364, but haven't dug in more deeply.

I suppose this can be closed, but hopefully this is useful to others who may have relied on mkdocstrings as sweeping in the Python handler by default.

@pawamoy
Copy link
Member

pawamoy commented May 29, 2022

Oh, so you only depended on mkdocstrings before? The new version stopped depending on the legacy handler, so you now have to explicitly depend on it (or the new handler), either directly or through the extras provided by mkdocstrings. The previous version of the legacy handler emitted a user warning about this. This was also explained in the docs: https://mkdocstrings.github.io/handlers/overview/#about-the-python-handlers. But it seems you already guessed all that 🙂 Yes it will be useful to others, thanks for reporting!

@pawamoy pawamoy closed this as completed May 29, 2022
@pawamoy pawamoy pinned this issue May 29, 2022
lyz-code added a commit to lyz-code/cookiecutter-python-project that referenced this issue Jun 8, 2022
fix: mkdocstring new requirement definition

mkdocstrings/mkdocstrings#436

ci: remove duplicate lint checks

test: correct version test
betsybookwyrm added a commit to DocNow/twarc that referenced this issue Oct 10, 2022
Fixes an error when running `mkdocs serve` for recent versions of
dependencies. See mkdocstrings/mkdocstrings#436
@pawamoy pawamoy unpinned this issue May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed This bug was not reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants