Building documentation raises error 'no module named sage_autodoc'

asked 2024-06-09 17:30:21 +0200

I am trying to figure out how to get sphinx to build documentation for a package. I have tried several sample packages from github and always get the same error, so it must be a problem in my personal installation.

For instance, following the instructions to build documentation of these packages:


I'm eventually asked to run

$ make doc

on the main folder of the package, to which I get

sphinx-build -b html -d build/doctrees   source build/html
Running Sphinx v4.3.2

Extension error:
Could not import extension sage_autodoc (exception: No module named 'sage_autodoc')
make: *** [Makefile:53: html] Error 2

I have SageMath version 9.5, Release Date: 2022-01-30, using Python 3.10.12. I have checked that there is indeed a module called sage_autodoc in my local installation, in the file sage_docbuild/ext/ For some reason, sage is not acknowledging it. Does anyone know how to solve this?

edit retag flag offensive close merge delete


Just a guess: if you run sage --buildsh first, that will start a new shell with various environment variables set, and those variables might help Python/Sphinx find the appropriate modules. You could try sage --buildsh -c "make doc".

John Palmieri gravatar imageJohn Palmieri ( 2024-06-09 20:35:07 +0200 )edit

I do run make doc within sage -sh for building the documentation of my package

Sébastien gravatar imageSébastien ( 2024-06-10 16:00:04 +0200 )edit

I have cloned your package (slabbe) and tried make doc as well as sage --buildsh -c "make doc". Both times the error still persists, but is different: Extension error: Could not import extension sage_autodoc (exception: cannot import name 'RemovedInSphinx80Warning' from 'sphinx.deprecation' (/usr/lib/python3/dist-packages/sphinx/

alvgutcac gravatar imagealvgutcac ( 2024-06-12 16:42:08 +0200 )edit

Maybe version 4.3.2 of Sphinx is too old and you need to upgrade?

John Palmieri gravatar imageJohn Palmieri ( 2024-06-12 18:38:50 +0200 )edit

Or maybe the Sphinx installed within SageMath 9.5 is not built with optional extensions like sage_autodoc? Is this the sagemath-9.5 available on Debian?

Sébastien gravatar imageSébastien ( 2024-06-12 22:21:48 +0200 )edit