I have a large directory structure so instead of manually adding the paths, i am searching for all modules using os.walk()
. Whenever I am finding a directory containing a __init__.py
file I am including that directory in the PYTHONPATH
by using the following code in my conf.py
file:
import os, sys
top = "/home/userme/Desktop/root"
for dirpaths, dirnames, filenames in os.walk(top):
if "__init__.py" in filenames:
sys.path.insert(0, os.path.abspath(dirpath))
I am also printing the filepaths to see that they are correct. Even then while trying to read the corresponding rst file I am getting an error trying to import the module.