I've been experiencing the same error. I have made two changes to generate the docs:
import .MyModule.X
with absolute import statements like import MyPackage.MyModule.X
.docs/conf.py
: Instead of specifying the desired directories via the option autoapi_dirs = ["../source1", "../source2", "../source3"]
, pointing it to the packages root directory autoapi_dirs = [".."]
and then specifying autoapi_ignore = ["*pattern1*", "*file2*", "*directory3*"]
to exclude all problematic files/directories. _Note that the asterisks *
where required to exclude the desired directories, like e.g. "directory3" to exclude all files in directory directory3/
.The second step I did because after changing the relative import statements I've been experiencing a further error described in this question.
Remark: I wanted to submit this as a comment, but I do not have enough "reputation". I hope this answer helps although I cannot explain the details.
sphinx-build -b html . _build
in a docs
directory located in the root folder of my project package.