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

ERROR: Could not import extension autoapi.sphinx (exception: No module named 'autoapi') when attempting to build docs #441

Open
calebregg52 opened this issue May 6, 2024 · 2 comments
Labels
Needed: Reproduction Case This issue needs a small test case to reproduce the issue before it can be worked on

Comments

@calebregg52
Copy link

Hello all, Im running into an issue sphinx cannot seem to locate the autoAPI extension. For reference I used pip install sphinx-autoapi and I included it in the extensions list in conf.py. Im currently running python 3.10 and sphinx 5.0.0.

Any help is much appreciated!

@AWhetter
Copy link
Collaborator

AWhetter commented May 18, 2024

Are you doing this inside a virtualenv (https://realpython.com/python-virtual-environments-a-primer/#create-it)?
What's the complete list of commands that you're running?

@AWhetter AWhetter added the Needed: Reproduction Case This issue needs a small test case to reproduce the issue before it can be worked on label May 18, 2024
@castlez
Copy link

castlez commented May 23, 2024

Just another data point here, i get the same thing if i run in a venv but not if i use system python (granted i still get an error, but i think its unrelated to this issue)

versions:

➜  python --version
Python 3.11.9
---------------
➜  sphinx-build --version
sphinx-build 7.3.7

Here's installing deps:

➜ pip install sphinx
➜ pip install sphinx_rtd_theme
➜ pip install sphinx-autoapi

Here's the commands

➜  tree .
.
├── build
│   └── _static
│       ├── jquery.js
│       └── _sphinx_javascript_frameworks_compat.js
├── code_src
│   ├── dummy.py
│   ├── __init__.py
│   └── __pycache__
│       ├── dummy.cpython-311.pyc
│       └── __init__.cpython-311.pyc
├── docs
│   ├── make.bat
│   ├── Makefile
│   └── source
│       ├── conf.py
│       └── index.rst
├── main.py
└── requirements.txt
➜  cd docs/source
➜  sphinx-build -b html . ../../build

and lastly here's the conf.py

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
templates_path = ["_templates"]
source_suffix = ".rst"
master_doc = "index"
suppress_warnings = ["autoapi"]


project = 'GitRequester'
copyright = '2024, Castle'
author = 'Castle'
release = '1.0.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'autoapi.extension',
    'sphinx.ext.viewcode'
]

autoapi_type = 'python'
autoapi_dirs = ['../../code_src']
autoapi_file_pattern = "*.py"
autoapi_options = ['members', 'private-members', 'show-inheritance',
                   'show-module-summary', 'special-members', 'imported-members', ]

exclude_patterns = ['build', 'Thumbs.db', '.DS_Store']
pygments_style = "sphinx"

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

and if its somehow helpful, when i install deps on my system python (managed by pyenv) and do the same i get this (lemme know if this is worth its own git issue)

➜  sphinx-build -b html . ../../build
Running Sphinx v7.3.7
WARNING: html_static_path entry '_static' does not exist
[AutoAPI] Reading files... [100%] /home/castle/src/sphinx_poc/code_src/__init__.py
[AutoAPI] Mapping Data... [100%] /home/castle/src/sphinx_poc/code_src/__init__.py
[AutoAPI] Rendering Data...

Extension error (autoapi.extension):
Handler <function run_autoapi at 0x7cced9cfc5e0> for event 'builder-inited' threw an exception (exception: [Errno 2] No such file or directory: '/home/castle/src/sphinx_poc/docs/source/autoapi/index.rst')

For what its worth, i have been using sphinx-autoapi for a while now, and only recently started seeing this. Hard to pinpoint because i dont redeploy docs everyday, but definitely in the last month this came up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: Reproduction Case This issue needs a small test case to reproduce the issue before it can be worked on
Projects
None yet
Development

No branches or pull requests

3 participants