1

经过多次搜索和尝试,我还没有找到解决这个问题的方法......

我正在使用 Sphinx 为 Python 包生成文档。您可以在此处查看代码:https ://github.com/jajimer/energym/tree/documentation 。我们感兴趣的包部分组织如下:

文件夹结构

energym/docs/source/conf.py我配置的路径如下:

import os
import sys

sys.path.insert(0, os.path.abspath('../../energym/'))

现在我正在尝试将这个模块及其所有组件energym/doc/source/pages/API-reference.rst的描述添加到 API 文档 () 中。utils为此,我正在使用 Sphinx 的autosummary

.. autosummary::
   :toctree: modules
   :template: custom-module-template.rst
   :recursive:
   
   utils

所以,在做完之后,和make clean && make html的文档是完美创建的,但不是. 根据 Sphinx 的说法,会发生以下异常:utils.commonutils.rewardsutils.rewardsutils.controllers

File "/home/user/projects/energym/energym/utils/controllers.py", line 8, in <module>
    from ..utils.common import parse_variables
ValueError: attempted relative import beyond top-level package

这是我的问题。我该如何解决?是相对路径问题吗?我已经看到问题是由于以下导入引起的:

from ..utils.common import parse_variables

但我真的不知道原因,因为路径似乎很完美。

4

0 回答 0