Where can I put a startup script in Jupyter?

Blaszard picture Blaszard · Aug 22, 2017 · Viewed 7.3k times · Source

I'm looking for a way to put my startup script in Jupyter. In IPython, I put it under the $IPYTHON_DIR/profile_default/startup/.

In Jupyter, it seems that the config file should be $JUPYTER_CONFIG_DIR/jupyter_notebook_config.py. However, I would like to use my startup file, which import a slew of Python libraries at the launch of the kernel.

Where can I put such file in Jupyter?

Answer

kingbase picture kingbase · Nov 1, 2017

You can get the default startup script folder via this in jupyter notebook:

get_ipython().profile_dir.startup_dir

On my Windows PC, the folder is: C:\Users\myusername\.ipython\profile_default\startup

And do read the README file under the folder.

    Files will be run in lexicographical order, so you can control
the execution order of files with a prefix, e.g.::

    00-first.py
    50-middle.py
    99-last.ipy

So you can put a file named 00-xx.py under the folder.