It is really simple in newer Jupyter:
%run MyOtherNotebook.ipynb
See here for details.
Official docs: %run IPython magic command
It is really simple in newer Jupyter:
%run MyOtherNotebook.ipynb
See here for details.
Official docs: %run IPython magic command
Install my helper library from the command prompt:
pip install import-ipynb
Import it from your notebook:
import import_ipynb
Now import your .ipynb notebook as if it was a .py file
import TheOtherNotebook
This import-ipynb module is just one file and it strictly adheres to the official howto on the jupyter site.
PS It also supports things like from A import foo, from A import * etc
PPS Works with subdirectories: import A.B
How do I import .ipynb Files?
python - Jupyter Notebook: Import .ipynb file and access it's method in other .ipynb file giving error - Stack Overflow
How to import functions from a .py file into a .ipynb file?
Trying to use a class in one Jupyter notebook in another; nothing I've tried works
I want to reuse code from an .ipynb file I created with jupyter notebook, but the documentation for importing those files into other ipynb files is really hard for me to understand.
[http://nbviewer.jupyter.org/github/jupyter/notebook/blob/master/docs/source/examples/Notebook/Importing%20Notebooks.ipynb ] Can someone help me?
Simple way to use ipynb files in jupyter note book are as follows:
1) Install import-ipynb
pip install import-ipynb
2) Import import_ipynb in jupyter notebook. Then import ipynb file as you import .py file
import import_ipynb
from test import print_name
print_name("your name")
**
Link to sample files on Drive
**
Ok. So, after some struggle and looking around on Internet, and finally found a solution that worked for my sample case.
Firstly, this is the stackoverflow question that was the most helpful to me. Mohideen and Tyhela's answer was the actual solution and not the one with most number of votes.
So, what I did was, I made a folder by the name module and placed all my .ipynb files there. Plus, I created an __init__.py file in that module by using touch __init__.py command such that the import can register it as a valid module. Those guys have given a detailed explanation for it which seems legit.
Then from my working directory I ran the following commands:
str = "Hello Me"
import test.abc as tabc
tabc.prt_n(str)
that gave me Hello Me in the output.
And for,
`import test.efg as tefg`
I got
importing Jupyter notebook from test/efg.ipynb
Hello Note
As my desired output.
I hope this will be of help to others who land up on similar problem.
If you have a better approach then I will appreciate if you can share that with me.
Thank you :)
» pip install importnb