ipynb icon indicating copy to clipboard operation
ipynb copied to clipboard

Load ipynb contained from a different directory

Open andrea-vandin opened this issue 3 years ago • 2 comments

Let us suppose my main notebook (main.ipynb) is next to a folder otherpath containing another notebook to be imported (to_be_imported.ipynb).

If I do import ipynb.fs.defs.otherpath.to_be_imported

I get ModuleNotFoundError: No module named 'ipynb.fs.defs.otherpath'

If I move to_be_imported.ipynb in the same folder of the main file, everything works.

andrea-vandin avatar Mar 06 '21 09:03 andrea-vandin

I have this same issue

FranklynSeabraOSF avatar Feb 16 '22 01:02 FranklynSeabraOSF

Seeems ipynb doesn't support package imports i.e.

|- package_a
   |- __init__.py
   |- module_a.ipynb
|- module_b.ipynb            import ipynb.fs.full.package_a.module_a

As a result, I've resorted to:

|- package_a
   |- module_a.ipynb
|- module_b.ipynb           import sys
                            import os
                            sys.path.insert(0, f"{os.getcwd()}/package_a")

                            import ipynb.fs.full.module_a

tobias-edwards avatar Aug 09 '22 17:08 tobias-edwards