简体   繁体   English

Sphinx:“未命名模块”

[英]Sphinx: “No module named”

I'm trying to build a documentation for my Python/Flask application using Sphinx, however I'm not able importing the file. 我正在尝试使用Sphinx为我的Python / Flask应用程序构建文档,但是无法导入该文件。

I import views.py file on views.rst , but an error message appears: No module named 'catalog' . 我在views.rst上导入views.py文件,但出现错误消息: No module named 'catalog'

Inside catalog folder has one __init__.py file, however anyway the error does not change. catalog文件夹中有一个__init__.py文件,但是无论如何该错误不会改变。

Would anyone know what is going on? 有人知道发生了什么吗?

Thank you in advance. 先感谢您。

views.rst views.rst

.. automodule:: catalog.views
   :members:

conf.py conf.py

sys_path.insert(0, os_path.abspath('../catalog'))

executive is the root folder and the files are: executive是根文件夹,文件是:

.
├── build
├── catalog
│   ├── __init__.py
│   └── views.py
├── source
│   ├── conf.py
│   ├── index.rst
│   └── views.rst

After some minutes later of asking this question, I've found the solution. 几分钟后问了这个问题,我找到了解决方案。

The problem was that I was passing the wrong path to sys path. 问题是我将错误的路径传递给sys路径。

In order to Sphinx "see" my catalog module, I've needed to point to the root folder and not the catalog module. 为了让Sphinx“看到”我的catalog模块,我需要指向根文件夹而不是catalog模块。

So, I've changed the conf.py file to: 因此,我将conf.py文件更改为:

sys_path.insert(0, os_path.abspath('..'))

And it started to work fine. 并且它开始运作良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM