pythonpython-sphinxautodoc

Python Sphinx Module Not Found


I have a subproject that I would like to document with python sphinx. It is structured this way: enter image description here

The documentation from the extraction_model went without any problems. But now, if I try to document the ocr part, I always get the warning:

WARNING: autodoc: failed to import module 'nfzOcr' from module 'nfz_extraction'; the following exception was raised:
No module named 'helperfunc'

and I don't really understand why, since both are in the same directory.

helperfunc is imported this way:

from helperfunc import dbDeleteRow, dbInsert, dbSelect

and the rst would be this:

.. automodule:: nfz_extraction.nfzOcr
   :members:

and the conf path would be this:

import os
import sys
sys.path.insert(0, os.path.abspath(".."))

It's working anyway with the documentation creation, but I still would like to know what I'm doing wrong with the import. Any suggestions?


Solution

  • Change

    from helperfunc import dbDeleteRow, dbInsert, dbSelect
    

    to

    from .helperfunc import dbDeleteRow, dbInsert, dbSelect
    

    That is the correct syntax for a relative import.