Sphinx 无法找到导入的源文件

问题描述

我对 sphinx 还是很陌生,正在努力让导入为 autodoc 模块工作。目前,我在 conf.py 中添加了以下路径

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

项目结构如下:

Project
|   __init__.py
|   setup.py
├───docs
│   │   make.bat
│   │   Makefile
|   |   conf.py
|   |   index.rst
|   |   module1.rst
│   ├─── _build
└───src
    |    module1.py
    |    module2.py
    |    __init__.py
    |    module3.py

Index.rst 内部如下:


    .. toctree::
        :maxdepth: 1
        :caption: Developer's Guide

        module1

最后,module1.rst 中的内容如下:

**src.module1**
==============================

.. automodule:: src.module1
    :members:
    :undoc-members:
    :show-inheritance:

但是,当我尝试使用 make html 构建文档时,出现以下错误

WARNING: autodoc: Failed to import module u'module1' from module u'src'; the following exception was raised:
No module named module2

现在奇怪的是,module1 不导入,甚至不接触 module2。有什么推荐吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)