Reputation: 63
Sphinx, the Python documentation generator, does not seem to understand my modules/packages. On make clean && make html
, when this code is ran: from statstuff import statistics as stats
, it outputs:
ImportError: No module named 'statstuff'
I have also tried to reference the module as from . import statistics as stats
, since the modules are in the same package, but Sphinx outputs:
SystemError: Parent module '' not loaded, cannot perform relative import
Also, the config.py
seems to be correctly configured as sys.path.insert(0, os.path.abspath('../statstuff/'))
, given that the documentation folder shares its parent folder with the statstuff folder.
Anyhow, here is the repository with the files: https://github.com/lucasmauro/statstuff
The problem occurs on statstuff/regression.py
, lines 2 and 3: https://github.com/lucasmauro/statstuff/blob/master/statstuff/regression.py
The code runs normally with the Python interpreters, but Sphinx fails to find the module as the code (or configuration) was written.
Does anyone have a clue on how to solve this?
Thank you very much indeed!
Upvotes: 5
Views: 2293
Reputation: 50947
Since your modules are in a package called statstuff
, I suggest the following:
Add the path to the directory above statstuff
to sys.path
in conf.py:
sys.path.insert(0, os.path.abspath('..'))
Edit the automodule
directives. Change
.. automodule:: probability
to
.. automodule:: statstuff.probability
and so on.
Upvotes: 4