Jupyter notes

From raju

list current notebooks

    jupyter notebook list

tags | list current servers

kill notebooks

    jupyter notebook stop 8888

tags | kill servers

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

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


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 = ''


    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


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

open ipynb files with double click

  • Install
    $ cat env_test_nbopen.yml
    name: test_nbopen
      - defaults
      - python=3.8
      - pywin32
      - pip
      - pip:
        - nbopen
    $ conda env create -f env_test_nbopen.yml

  • Add the following at the beginning of PATH


where PY38 is your python environment. Ex:- C:\ProgramData\Continuum\Anaconda\envs\test_nbopen .

  • Integrate with the file manager
    python3 -m nbopen.install_win