Importing IPython Notebooks as Modules

Wouldn't it be cool to import Jupyter Notebook just as a Python module? Well, there is a convenient way, you just need to add one line to your Jupyter configuration to execute several Python functions. So, do:

1. Generate the profile files.

$ jupyter notebook --generate-config


2. Edit the to append:

c.InteractiveShellApp.exec_files = [ "/home/you/.jupyter/" ]

Where the should be the path to the following file: (gist).

Then, you will be able to import other Jupyter notebooks just like Python libraries :)

3. N.B.:

Additionally, you just need an empty file in your root folder of IPython Notebook, and in every deeper level folder which you want to import from. With that, if you have a folder named "nbpackage" and "mynotebook.ipynb" inside it, you can do:

from nbpackage import mynotebook

Or simply

import mynotebook

if you are in the folder already. Works just like Python package imports.