简体   繁体   中英

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.

I import views.py file on views.rst , but an error message appears: No module named 'catalog' .

Inside catalog folder has one __init__.py file, however anyway the error does not change.

Would anyone know what is going on?

Thank you in advance.

views.rst

.. automodule:: catalog.views
   :members:

conf.py

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

executive is the root folder and the files are:

.
├── 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.

In order to Sphinx "see" my catalog module, I've needed to point to the root folder and not the catalog module.

So, I've changed the conf.py file to:

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

And it started to work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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