Imports in nested notebooks

Suppose I have the following folder structure in my notebook’s directory:

nbs/

  • submodule/
    ---- funcA.ipynb
    ---- funcB.ipynb
  • func1.ipynb
  • func2.ipynb
  • lib_name(sym_link)

The instruction recursive=True is correctly creating the module structure for the .py files. When I import func1 from func2:

from lib_name import func2. 

it works because there is the lib_name folder.
Suppose that I import funcA from funcB:

from lib_name.submodule import funcA. 

this would not work unless I create a new symbolic link in the submodule folder.
Is there a way to automate this?
Or what strategy would work the best with nested notebooks and their corresponding .py modules?

In every notebook before the imports, I added:

import sys
sys.path.append('path/to/nbs')

and it seems to be working

1 Like