我尝试使用Sphinx-doc的自动文档功能。我想解决以下问题。目前,来自StackOverflow的解决方案都没有起作用。这是由于我的项目结构还是我选择导入模块的方式所致?
给出文件的结构:
project
|_ src
| |_ pre_processing
| | |_ fileInfo.py
| |
| |_ utils
| |_ folder.py
|_ test
|
|_ doc
| |_ doc_user
| |_ build
| |_ source
| |_config.py
以下是 config sys.path :
import os
import sys
sys.path.insert(0, os.path.abspath('../../../src/'))
我在fileInfo.py中有一些相对导入,如下:
from ..utils.folder import get_files_directory
终端错误
WARNING: autodoc: failed to import module 'pre_processing.fileInfo'; the following exception was raised:
Traceback (most recent call last):
File "/home/florian-stage/miniconda/envs/gd/lib/python3.5/site-packages/sphinx/ext/autodoc/importer.py", line 140, in import_module
__import__(modname)
File "/home/florian-stage/Projet-2018/pg_georef_data-master/arbo propre/src/pre_processing/fileInfo.py", line 12, in <module>
from ..utils.folder import get_files_directory
ValueError: attempted relative import beyond top-level package
config.py
吗?通常的名称是conf.py
。请参阅http://www.sphinx-doc.org/en/master/usage/configuration.html。 - mzjn