I am trying to build my documentation on Read the Docs but I am getting a dreaded "Module not found" error. If I issue make docs
locally in my project's root, everything builds fine so the "Module not found" error is very strange to me.
I am using the PyPackage Cookiecutter template. Here is my project's relavent portion of its tree:
.
├── docs
│ ├── authors.rst
│ ├── conf.py
│ ├── contributing.rst
│ ├── history.rst
│ ├── index.rst
│ ├── installation.rst
│ ├── make.bat
│ ├── modules.rst
│ ├── readme.rst
│ ├── scattergrid.rst
│ └── usage.rst
├── requirements_dev.txt
├── scattergrid
│ ├── __init__.py
│ ├── cli.py
│ └── scattergrid.py
├── setup.cfg
├── setup.py
├── tests
│ ├── __init__.py
│ └── test_scattergrid.py
└── tox.ini
Below is the successful local build in the same project issuing make docs
in the root:
Running Sphinx v3.0.4
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 9 source files that are out of date
updating environment: [new config] 9 added, 0 changed, 0 removed
reading sources... [100%] usage
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] usage
generating indices... genindex py-modindexdone
highlighting module code... [100%] scattergrid.scattergrid
writing additional pages... searchdone
copying static files... ... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.
The HTML pages are in _build/html.
python -c "$BROWSER_PYSCRIPT" docs/_build/html/index.html
Below is the error from Read the Docs:
Running Sphinx v1.8.5
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/config.py", line 368, in eval_config_file
execfile_(filename, namespace)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/util/pycompat.py", line 150, in execfile_
exec_(code, _globals)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/checkouts/latest/docs/conf.py", line 20, in <module>
import scattergrid
ModuleNotFoundError: No module named 'scattergrid'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/cmd/build.py", line 300, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/application.py", line 201, in __init__
self.config = Config.read(self.confdir, confoverrides or {}, self.tags)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/config.py", line 203, in read
namespace = eval_config_file(filename, tags)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/config.py", line 380, in eval_config_file
raise ConfigError(msg % traceback.format_exc())
sphinx.errors.ConfigError: There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/config.py", line 368, in eval_config_file
execfile_(filename, namespace)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/util/pycompat.py", line 150, in execfile_
exec_(code, _globals)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/checkouts/latest/docs/conf.py", line 20, in <module>
import scattergrid
ModuleNotFoundError: No module named 'scattergrid'
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/config.py", line 368, in eval_config_file
execfile_(filename, namespace)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/envs/latest/lib/python3.8/site-packages/sphinx/util/pycompat.py", line 150, in execfile_
exec_(code, _globals)
File "/home/docs/checkouts/readthedocs.org/user_builds/scattergrid/checkouts/latest/docs/conf.py", line 20, in <module>
import scattergrid
ModuleNotFoundError: No module named 'scattergrid'
Here is the exact line where this error occurs in docs/conf.py
.
import scattergrid
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
This was setup by the cookiecutter template and you can see the absolute path is pointing one level up from the docs folder. Everything builds on Read the Docs if I don't include import scattergrid
but of course then I don't have any real documentations so any help would be very appreciated!
Here is docs/scattergrid.rst
built from the cookiecutter template:
scattergrid package
===================
Submodules
----------
scattergrid.cli module
----------------------
.. automodule:: scattergrid.cli
:members:
:undoc-members:
:show-inheritance:
scattergrid.scattergrid module
------------------------------
.. automodule:: scattergrid.scattergrid
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: scattergrid
:members:
:undoc-members:
:show-inheritance: