This Jupyter extension allows you to create a default cell and run it whenever a new notebook is generated. This is useful for constant imports you always use (like import numpy as np
and import pandas as pd
)
run:
pip install jupyter_contrib_nbextensions && jupyter contrib nbextensions install
If you happen to get an [Errno 13] Permission denied ...
, try adding --user
at the end of the command.
-
First, find the extensions folder of
nbextensions
. You can do so by running:pip show jupyter-contrib-nbextensions
. The output will contain aLocation
section (something like:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
) -
Go to
{Location}/jupyter_contrib_nbextensions/nbextensions/
, and place thedefault_cell
folder in there (keeping the files in thedefault_cell
directory) -
run
jupyter contrib nbextensions install [--user]
(you'll need to add--user
if you needed it before)
Before the first use, activate the extension under the NB Extensions
tab.
Two configurations are available:
- Cell Input: the text which will be executed. Use
<br>
for new-lines - Run Automatically: whether to run the cell on startup or not
Based on the code and instructions of this blogpost by Will Koehrsen.