我是 sphinx 的新手,需要帮助找出为什么出现以下错误:
WARNING: autodoc: failed to import module 'employe_dao' from module 'models'; the following exception was raised:
No module named 'models'
Run Code Online (Sandbox Code Playgroud)
我的项目结构是:
|--master_project
|--sub_project
|--docs
|--build
|--conf.py
|--index.rst
|--Makefile
|--models.rst
|--src.models.rst
|--src.rst
|--src
|--models
|--employee.py
...
|--__init__.py
|--data_extractor.py
|--optimiser.py
enter code here
...
Run Code Online (Sandbox Code Playgroud)
这是来自的片段index.rst
...
.. toctree::
:maxdepth: 2
:caption: Contents:
.. automodule::src
:members:
:undoc-members:
:show-inheritance:
.. automodule::models
:members:
:undoc-members:
:show-inheritance:
...
* :ref:`modindex`
Run Code Online (Sandbox Code Playgroud)
我已按照 Sphinx 中的建议添加sys.path.insert(0, os.path.abspath('./sub_project'))并取消注释: autodoc can`t import moduleimport os, import …
我有一个关于 Sphinx 自动文档生成的问题。我觉得我想做的事情应该很简单,但由于某种原因,它不起作用。
我有一个 Python 项目,其目录名为slotting_tool。该目录位于C:\Users\Sam\Desktop\picnic-data-shared-tools\standalone\slotting_tool
我使用sphinx-quickstart. 那么我的目录结构(简化)如下:
slotting_tool/
|_ build/
|_ source/
|___ conf.py
|___ index.rst
|_ main/
|___ run_me.py
Run Code Online (Sandbox Code Playgroud)
现在,我slotting_tool通过将以下内容添加到conf.py文件中来设置项目的根目录。
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
Run Code Online (Sandbox Code Playgroud)
接下来,我将我的index.rst文件更新为如下所示:
.. toctree::
:maxdepth: 2
:caption: Contents:
.. automodule:: main.run_me
:members:
Run Code Online (Sandbox Code Playgroud)
尝试使用该sphinx-build -b html source .\build命令构建我的 html 时,我得到以下输出,并显示no module named错误:
(base) C:\Users\Sam\Desktop\picnic-data-shared-tools\standalone\slotting_tool>sphinx-build -b html source .\build
Running Sphinx v1.8.1
loading pickled environment... done
building [mo]: targets for …Run Code Online (Sandbox Code Playgroud)