2

I try to generate my PyQGIS plugin documentation with Sphinx.

I made a Python virtualenv based on the QGIS environment and initiated my Sphinx doc with the package already installed in it.

But when I generate the HTML doc, I get this error :

WARNING: autodoc: failed to import module 'mymodule' from module 'mainmodule'; the following exception was raised: No module named 'qgis'

How can I tell Sphinx where to find QGIS?

1

1 Answer 1

1

The best solution I found is to remove my Sphinx from the standard Python installation and install it inside my venv.

But then, I get another error:

No module named 'processing' 

I tried to add the path to the processing plugin in my QGIS installation folder in the conf.py :

import os import sys from qgis.core import QgsApplication sys.path.insert(0, os.path.abspath(os.path.join(QgsApplication.pkgDataPath(), "python/plugins"))) 

which doesn't work (I verified the value of os.path.abspath(os.path.join(QgsApplication.pkgDataPath(), "python/plugins"))), which points well to the processing directory.

os.path.join(QgsApplication.pkgDataPath(), "python/plugins") returns only a complete QGIS path within the QGIS Python console; otherwise, QgsApplication needs to be initialised with a QGIS path. The simplest way to get the QGIS path is to hardcode it directly in the conf.py

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.