rmmariano
rmmariano

Reputation: 976

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

Upvotes: 3

Views: 5198

Answers (1)

rmmariano
rmmariano

Reputation: 976

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.

Upvotes: 3

Related Questions