I have a notebook which I intend to use as a library for other notebooks.
It has some functions that can ready certain types of files etc.
How can I include that notebook in a new notebook that should be able to use the functions in the library notebook?
googling for notebook import hook
yield some examples. This is still experimental, but you are welcomed to improved it. I would suggest also using the --script
flag that save an importable .py
file every time you save the notebook.
You can just enter %run 'NotebookA.ipynb'
in Notebook B and you should be good to go!
With import_ipynb
library using A.ipynb
from B.ipynb
is as simple as writing
import import_ipynb
import A
in B.ipynb
.
Actually this library is just one file I've taken from the official jupyter howto and wrapped into a package installable via
pip install import-ipynb
It's also possible to write from A import foo
, from A import *
and so on.