0

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.

hank
  • 9,553
  • 3
  • 35
  • 50
  • I am using virtualenvwrapper so also take that into account. – Rajdeep Mukherjee Jul 12 '17 at 06:44
  • I just noticed a typo in my code written in the question `for dirpaths, dirnames, filenames in os.walk(top):`, please note that it would be `dirpath`. That was correct, even then the error for `no module` persisted. – Rajdeep Mukherjee Jul 12 '17 at 06:52

0 Answers0