ipynb
ipynb copied to clipboard
Load ipynb contained from a different directory
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.
I have this same issue
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