Jupyter

jupyter

Launch Jupyter server

jupyter notebook
  • Go to notebooks folder
  • Open the file 03.JupyterQuickStart.ipynb

Make a Copy

Before modifying the notebook, make a copy of it. Go to to File menu on the top left of the notebook and click on Make a Copy...

Jupyter Notebook

Jupyter notebook, formerly known as the IPython notebook, is a flexible tool that helps you create readable analyses, as you can keep code, images, comments, formulae and plots together.

Jupyter is quite extensible, supports many programming languages and is easily hosted on your computer or on almost any server — you only need to have ssh or http access. Best of all, it’s completely free.

The name Jupyter is an indirect acronyum of the three core languages it was designed for: JUlia, PYThon, and R

Keyboard Shortcuts

  • To access keyboard shortcuts, use the command palette: Cmd + Shift + P

  • Esc will take you into command mode where you can navigate around your notebook with arrow keys.

  • While in command mode:

    • A to insert a new cell above the current cell, B to insert a new cell below.
    • M to change the current cell to Markdown, Y to change it back to code
    • D + D (press the key twice) to delete the current cell

Magic commands

%lsmagic
%ls *.ipynb
%%file sample.txt

write the cell content to the file sample.txt.
The file is created when you run this cell.
%cat sample.txt
%%file fibonacci.py

f1, f2 = 1, 1
for n in range(10):
    print(f1, end=',')
    f1, f2 = f2, f1+f2
%run fibonacci.py
# %load fibonacci.py

f1, f2 = 1, 1
for n in range(10):
    print(f1, end=',')
    f1, f2 = f2, f1+f2
%%time
f1, f2 = 1, 1
for n in range(10):
    print(f1, end=',')
    f1, f2 = f2, f1+f2
print()

Installing Python Packages from a Jupyter Notebook

Install a conda package in the current Jupyter kernel

Example with package numpy from conda-forge

%conda install -c conda-forge numpy

Install a pip package in the current Jupyter kernel

%pip install numpy