Python Sphinx Module Not Found

Question:

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?

Asked By: user3793935

||

Answers:

Change

from helperfunc import dbDeleteRow, dbInsert, dbSelect

to

from .helperfunc import dbDeleteRow, dbInsert, dbSelect

That is the correct syntax for a relative import.

Answered By: mzjn
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.