简体   繁体   English

Python 找不到 Sphinx 模块

[英]Python Sphinx Module Not Found

I have a subproject that I would like to document with python sphinx.我有一个子项目,我想用 python 狮身人面像来记录。 It is structured this way:它的结构是这样的: 在此处输入图像描述

The documentation from the extraction_model went without any problems.来自 extraction_model 的文档没有任何问题。 But now, if I try to document the ocr part, I always get the warning:但是现在,如果我尝试记录 ocr 部分,我总是会收到警告:

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: helperfunc 以这种方式导入:

from helperfunc import dbDeleteRow, dbInsert, dbSelect

and the rst would be this:第一个是这样的:

.. automodule:: nfz_extraction.nfzOcr
   :members:

and the conf path would be this:并且 conf 路径是这样的:

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 .这是相对导入的正确语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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