Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I put a startup script in Jupyter?

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?

like image 358
Blaszard Avatar asked Aug 22 '17 13:08

Blaszard


People also ask

Where is the Startup folder in Jupyter Notebook?

To launch Jupyter Notebook App: Click on spotlight, type terminal to open a terminal window. Enter the startup folder by typing cd /some_folder_name . Type jupyter notebook to launch the Jupyter Notebook App The notebook interface will appear in a new browser window or tab.

How do I run a script in Jupyter Notebook?

Inside the Notebook. When you open a new Jupyter notebook, you'll notice that it contains a cell. Cells are how notebooks are structured and are the areas where you write your code. To run a piece of code, click on the cell to select it, then press SHIFT+ENTER or press the play button in the toolbar above.


1 Answers

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.

like image 169
kingbase Avatar answered Oct 18 '22 20:10

kingbase