python - Sphinx autodoc 无法导入模块
问题描述
我正在尝试使用 Sphinx 记录一个项目,并且遇到了一个问题,即仅从文件夹中导入了一些模块。我的项目结构如下所示:
Project
|
|--Main
| |--Scripts
| __init__.py
| libsmop.py
| conv_table.py
| f_discrim.py
| recipes.py
| ...
当我尝试运行make html
时,libsmop
并且recipes
导入时没有任何问题,但是conv_table
并f_discrim
收到以下错误:
WARNING: autodoc: failed to import module u'conv_table' from module u'Scripts'; the following exception was raised:No module named conv_table
我不认为这是我的配置文件,因为它会在我运行时找到所有文件,sphinx-apidoc -o _rst Main/Scripts
并且我已经确认它们出现在结果Scripts.rst
文件中。
为什么 autodoc 会找到一些模块而不是其他模块?
编辑:
conv_table.py
是这种形式:
import re
import numpy as np
"""
conv_table dictionary at the bottom of this file maps from matlab functions
to their python equivalents.
"""
def get_args(line,separator=",", open_char='(', close_char=')'):
"""Returns the arguments of line
>>> get_args('ones(3,1,length(arr))')
...
< a bunch of function definitions>
...
conv_table = {... < a very big dictionary > ...}
解决方案
由于您的 autodoc 正在获取一些模块,因此可能是因为失败模块的依赖项要么是 1)未正确导入,要么是 2)未安装在您的 python 环境下。您将需要检查所有导入语句是否在失败的模块中工作。
推荐阅读
- javascript - 将数据传输到另一个文件中的 PHP 数组后,jQuery 数组的数据不会显示在数据库中
- react-native - React Native TextInput returnKeyType 不起作用
- sql-server - SQL Server 在 DBI::dbSendStatement() 和 DBI::dbBind() 中使用了错误的数据类型
- reactjs - React 重新渲染不必要的组件
- r - R为多个(相似)变量(eq.var1,var2,var3)重复case_when
- shell - 如何在 perl 中将 ascii 编码文件转换为 utf-8 编码?
- hadoop - 如何在 Hive 中透视数据?
- sql - 如何在 ssms 中对打开的 sql server 表进行排序
- node.js - 节点 - 收集作业并将它们作为具有超时的批次使用
- dart - 比较对象时 == 运算符在飞镖中究竟是如何工作的?