Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

Default template for iPython notebook (using Jupyter)

In the first cell of every iPython (Jupyter) notebook, I almost always type:

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

Is there a way to make it so that this cell appears at the top of each new notebook I create by default?

For example, could I save a template .ipynb file somewhere, which is copied by iPython when creating a new notebook?

(I found this question, but it seems to be more about css than default content in cells.)

question from:https://stackoverflow.com/questions/34002326/default-template-for-ipython-notebook-using-jupyter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...