How to Install Jupyter and Create Your First Notebook

How to Install Jupyter and Create Your First Notebook

Installing Jupyter Notebook with pip and creating your first notebook.

What Is a Jupyter Notebook

So, you are learning Python and maybe you've even written some cool scripts but you've seen all these notebooks around with explanatory text, data, images, and results. This is where Jupyter comes in, a jupyter notebook is like an interactive Python terminal that records every step of the way and allows you to add rich text along the way.

jupyter preview courtesy jupyter.org

From the official docs: "Notebook documents contains the inputs and outputs of a interactive session as well as additional text that accompanies the code but is not meant for execution. In this way, notebook files can serve as a complete computational record of a session, interleaving executable code with explanatory text, mathematics, and rich representations of resulting objects."

Installing With pip

Let's start by installing notebook with this command:

pip install notebook

pip install notebook command After the install completes we can move on to running the command:

jupyter notebook

jupyter notebook command

Running the jupyter notebook command will open a browser window to the notebook dashboard (as will following the links it sent back)

The Notebook Dashboard

jupyter notebook dashboard

The dashboard gives us an overview of our notebooks and kernels.

Creating Our First Notebook

From the dashboard we can click the new button and create our first Python 3 (ipykernel) notebook:

new notebook

A new browser tab will open with a new notebook.

new browser tab with notebook

Let's name and save our notebook.

name and save notebook

Adding Our First Blocks

Let's change the first block from a code block to a markdown block. Select the block and press the (m) key to change it's type to markdown, the (y) key will change it back into a code block.

add markdown block

Then add a code block and run it to see the output.

add code block

All of this is contained within the notebook. Let's go ahead and run all of our cells from the cell menu so that the markdown is also rendered.

run all cells

Saving Our Notebook

Next I will save it as a notebook.

saving as notebook

And lastly I uploaded it to GitHub to see it in all of it's glory.

notebook on github

Here is the link to the file on my GitHub. DAVESFIRSTNOTEBOOK.ipynb Until next time, DAVE.