Sphinx-AutoAPI Error: "'Module' object has no attribute 'doc'" with Various Sphinx Versions
Asked Answered
B

1

6

I'm relatively new to using Sphinx and I've encountered an issue that I'm struggling to solve. I suspect the error might be related to the version of Sphinx I'm using, but attempts to resolve it with different versions have been unfruitful.

sphinx-build -b html docs/sphinx/source docs/sphinx/build

loading pickled environment... failed: Can't get attribute '_stable_repr_object' on <module 'sphinx.builders.html' from 'C:\\Users\\johndoe\\.conda\\envs\\johndoe_env\\lib\\site-packages\\sphinx\\builders\\html\\__init__.py'>
done
myst v2.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'amsmath', 'html_image', 'dollarmath', 'html_admonition', 'colon_fence', 'smartquotes', 'replacements', 'substitution', 'tasklist', 'strikethrough', 'deflist', 'fieldlist'}, disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_
domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=2, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, 
mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
2023-10-09T09:47:51.246657 [warning  ] C:\Users\johndoe\.conda\envs\johndoe_envs\lib\site-packages\autoapi\mappers\python\mapper.py:293: RemovedInSphinx80Warning: The alias 'sphinx.util.status_iterator' is deprecated, use 'sphinx.util.display.status_iterator' instead. Check CHANGES for Sphinx API modifications.
  for dir_root, path in sphinx.util.status_iterator(
 thread_id=15556
[AutoAPI] Reading files... [  4%] C:\Users\johndoe\PycharmProjects\BE\app\main.py
Extension error (autoapi.extension):
Handler <function run_autoapi at 0x000001A007B27AC0> for event 'builder-inited' threw an exception (exception: 'Module' object has no attribute 'doc')

Tried Solutions:

I have tried using different versions of Sphinx and Sphinx-AutoAPI. Specifically:

  • Sphinx: 4.5 and 7.2.6
  • Sphinx-AutoAPI: 2.1.0 and 1.2.1

All of the above were sourced from conda forge, but the issue persists.

Environment:

Here’s my conda environment setup in environment.yml:

  - sphinx-book-theme
  - myst-parser
  - sphinx-autodoc-typehints
  - graphviz
  - linkify-it-py
  - mistune=0.8.4
  - sphinx-autoapi=2.1.0
  - sphinxcontrib-openapi
  - sphinx=4.5  # working version, 5+ seems not to work
  1. What might be causing the "Module object has no attribute 'doc'" error?
  2. Is this issue truly related to Sphinx versioning, or could there be another underlying issue?

Any guidance on how to resolve this issue would be greatly appreciated. Thank you in advance!

Bayne answered 9/10, 2023 at 8:3 Comment(4)
I had the same problem running sphinx==4.5.0 and sphinx-autoapi==1.8.4. It only started recently failing without any particular changes to my docs or explicit version requirements. I decided to update these requirements and with sphinx==6.2.1 and sphinx-autoapi==3.0.0 it is working again.Doorpost
Thank you, that worked for me! Since my entire environment is built with Conda, I wanted to use the Conda Forge version of autoapi. However, the latest version available there is only 2.1.0. Nevertheless, version 3.0.0 also works for me.Bayne
@Doorpost please consider posting this as an answer - looks like a solution that should be see and may help other people in future.Wyck
@sterliakov seems like the OP beat me to it. Didn't want to post it as an answer initially since I wasn't sure it was actually going to solve the issue. But seems like the problem is fixed and it is marked as an answer, so all goodDoorpost
B
1

Solution:

Upgrade AutoAPI:

Despite using Conda, I decided to test the newer version of sphinx-autoapi. I found that version 3.0.0 (Pypi) works for my case, even though it is not available on Conda Forge.

Bayne answered 9/10, 2023 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.