python - 从父目录导入子目录模块时出现 Sphinx ImportError

标签 python html makefile python-sphinx importerror

我是新来的。正在谷歌搜索,找不到有关我的问题的任何答案。

我正在尝试使用 sphinx 创建一个文档,扩展名为“sphinx.ext.autodoc”。 sphinx文档和源代码是完全分开的。因此,“myproject”和“subdir”的路径包含在 sphinx 的 conf.py 的 sys.path 中。

现在我尝试在“moduleB.py”中使用以下导入:from myproject.moduleA import myClass

当我运行“make html”时,结果是一个 ImportError:没有名为 myproject.moduleA 的模块。

我的项目

├── __init__.py
├── moduleA.py
└── subdir
    ├── __init__.py
    └── moduleB.py

希望有人能帮忙:)

最佳答案

我自己想出来的:D 要引用 myproject.moduleA,myproject (..) 的父目录也必须位于 sys.path 中。 我的 sys.path 中只有 myproject 和子目录:/

关于python - 从父目录导入子目录模块时出现 Sphinx ImportError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35200651/

相关文章:

asp.net - Python Django 与 ASP.NET MVC

python - 如何使用数学模块(Python 3)四舍五入到 32

javascript - 延迟一段时间后显示第二个 div,如果鼠标悬停在第一个或第二个 div 上,则保持第二个 div 可见

jquery - 使用 jQuery 从 textarea 中删除标签

python - 连接到 mercurial pretxncommit。并且不能导入请求模块?

python - 使用 Python 进行多峰数据拟合

javascript - 如何通过 AJAX 将 HTML5 sqlite 结果集发送到服务器

makefile - 在与 src 不同的目录中构建输出的 GNU Make 模式

nginx - 编译nginx失败: undefined reference to `SSL_get0_alpn_selected' and `SSL_CTX_set_alpn_select_cb'

C++ 生成文件错误 : No rule to make target