Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up default startup commands in iPython notebooks?

I want to put couple of cells with commands I need in almost every new notebook in every new notebook I create.

For example when I create a new notebook it should put a

%matplotlib inline
import matplotlib.pyplot as plt

in a cell by default but not execute it. How could I set something like that up?

like image 244
user9886 Avatar asked Feb 06 '15 10:02

user9886


People also ask

How do I change the Startup folder in Jupyter lab?

In the start menu, right click Jupyter Notebook -> Properties . In the Target field, change %USERPROFILE% to your new "D:\path" .

How do I change the settings on my Jupyter notebook?

To create a jupyter_notebook_config.py file in the . jupyter directory, with all the defaults commented out, use the following command: $ jupyter notebook --generate-config :ref:`Command line arguments for configuration <config>` settings are documented in the configuration file and the user documentation.

Where is IPython Profile_default startup?

Generally, the default location is /Users/<your_profile>/. ipython/profile_default/startup in Mac. You can find your startup directory by running this in a Jypyter Notebook cell.


1 Answers

This will work for both terminal based IPython shell and Browser based Notebook:

  • Navigate to ~/.ipython/profile_default
  • Create a folder called startup if it’s not already there
  • Add a new Python file called start.py
  • Put your favorite imports (and custom functions may be) in this file
  • Launch IPython or a Jupyter Notebook and your favorite libraries will be automatically loaded every time!

Here is my sample for start.py: enter image description here

Another Source

like image 114
Umair Qadir Avatar answered Oct 24 '22 20:10

Umair Qadir