Default template for iPython notebook (using Jupyter)

I know it may not be what you're looking for (this example is not good for working on notebooks that need to be run in multiple environments, e.g. shared), but I put the following in a file called ipython_config.py in my .ipython folder.

c.InteractiveShellApp.exec_lines = ['%matplotlib inline',
    'import numpy as np',
    'import scipy.constants as scc',
    'import scipy.integrate as sci',
    'from mpl_toolkits.mplot3d import Axes3D',
    'import scipy.optimize as sco'
]

This runs before anything runs in any interactive console, including the jupyter notebook. If you want explicit boilerplating, I think that you will be disappointed (unless you want to build in the functionality for us ☺)


There is a pretty cool solution using jupyterlab: jupyterlab_templates

Installation took about 5 minutes and you can have as many

templates as you'd like.

Mac Users

Assuming you have conda installed than during the installation, you'll need to install node js engine:

  • conda install -c conda-forge nodejs

And create a jupter_noteook_config.py if you don't have one :

  • jupyter notebook --generate-config