Jupyter notes

From raju

keyboard shortcuts

  • comment out block of code - ctrl + /
  • Block unindent - ctrl + [
  • Block indent - ctrl + ]

start server

    # cd to a top level directory containing all the notebooks
    # Activate the environment if necessary
    jupyter notebook
    

start server in a different conda environment

To start the jupyter notebook in a different environment

    source activate foo
    jupyter notebook
    ctrl-c
    

list the current notebooks

To list the current notebooks

    jupyter notebook list
    

features missing

aka things I have to figure out

  • move cells up and down using mouse

useful links

select multiple cells

Use keyboard and not mouse. Click somewhere in the black area to the left of cell content and use arrow keys.

script dump

    jupyter nbconvert --to script --stdout foo.ipynb
    

Related

to install jupyter notebook

jupyter notebook comes with the jupyter package. To install it

    python3 -m pip install --upgrade pip
    python3 -m pip install jupyter
    

Ref:- https://jupyter.org/install

launch jupyter notebook in chrome

machine | windows 10

  • launch git bash
  • Activate an environment that contains jupyter notebook
    source activate <env>
  • generate config
    jupyter notebook --generate-config
  • In ~/.jupyter/jupyter_notebook_config.py, change
    #c.NotebookApp.browser = ''

to

    c.NotebookApp.browser = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

Ref:- https://stackoverflow.com/questions/46829761/how-to-open-jupyter-notebook-in-chrome-on-windows

launch jupyter notebook in the background

machine | windows 10

My script: https://github.com/KamarajuKusumanchi/rutils/blob/master/bin/jn.daemon

Usage:

jn.daemon [start|stop|status] <root_dir>
root_dir is optional. It is set to current directory by default.

underlying commands:

  • To start the server
    jupyter notebook > /dev/null 2>&1 &
    
  • To stop the servers
    ps -W | grep "jupyter-notebook" | awk "{print \$1}" | xargs kill -f
    

See also: https://stackoverflow.com/questions/38118217/how-can-i-run-jupyter-notebook-in-background-on-windows

nbviewer not showing the latest version

This is an nbviewer FAQ. Basically it takes about 10 minutes to update, but if you want to force it, you can add ?flush_cache=true to the nbviewer URL.

Ref:- https://stackoverflow.com/questions/29034001/i-updated-my-ipython-notebook-gist-but-why-didnt-nbviewer-update