简体   繁体   中英

Python Sphinx Module Not Found

I have a subproject that I would like to document with python sphinx. It is structured this way: 在此处输入图像描述

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?

Change

from helperfunc import dbDeleteRow, dbInsert, dbSelect

to

from .helperfunc import dbDeleteRow, dbInsert, dbSelect

That is the correct syntax for a relative import .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM