100% found this document useful (1 vote)
142 views

Introduction To Anaconda and Jupyter Notebooks

The document introduces Anaconda and Jupyter Notebooks. It discusses that Jupyter Notebook allows creating and sharing documents with code, equations, visualizations and text. It provides steps to install Anaconda, which includes Jupyter Notebook and many data science packages. After installing Anaconda, it describes how to launch Jupyter Notebook and create a new notebook, adding code cells that can be run to display output.

Uploaded by

20105167
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
142 views

Introduction To Anaconda and Jupyter Notebooks

The document introduces Anaconda and Jupyter Notebooks. It discusses that Jupyter Notebook allows creating and sharing documents with code, equations, visualizations and text. It provides steps to install Anaconda, which includes Jupyter Notebook and many data science packages. After installing Anaconda, it describes how to launch Jupyter Notebook and create a new notebook, adding code cells that can be run to display output.

Uploaded by

20105167
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

INTRODUCTION TO ANACONDA

AND JUPYTER NOTEBOOKS

Overview........................................................................................................................................................3

Jupyter Notebook...........................................................................................................................................3

Installing Anaconda.......................................................................................................................................3

LAUNCHING ANACONDA........................................................................................................................8

Starting the Jupyter Notebook Server............................................................................................................9

Creating a Notebook....................................................................................................................................10

Naming.........................................................................................................................................................10

Running Cells...............................................................................................................................................11

The Menus....................................................................................................................................................11

File Menu.................................................................................................................................................12

Edit Menu.................................................................................................................................................12

The View Menu........................................................................................................................................12

The Insert Menu.......................................................................................................................................12

The Cell Menu..........................................................................................................................................12

The Kernel Menu.....................................................................................................................................13

The Widgets Menu...................................................................................................................................13

The Help Menu........................................................................................................................................13

Adding Rich Content....................................................................................................................................13

Styling Your Text - Markdown................................................................................................................13

Headers.....................................................................................................................................................15

Creating Lists...........................................................................................................................................16
Overview
The Jupyter Notebook is an open-source web application that you can use to create and share documents that
contain live code, equations, visualizations, and text.

Jupyter Notebook is maintained by the people at Project Jupyter. Jupyter Notebooks are a spin-off project
from the IPython project, which used to have an IPython Notebook project itself. The name, Jupyter, comes
from the core supported programming languages that it supports: Julia, Python, and R. Jupyter ships with
the IPython kernel, which allows you to write your programs in Python, but there are currently over 100
other kernels that you can also use.

Jupyter Notebook
The Jupyter Notebook is not included with Python, so if you want to use it, you must install Jupyter directly
or using Anaconda. Anaconda is a distribution of packages built for data science including everything that
we need for this module under one roof. Without Anaconda you would have to install and manage each
separately.

Installing Anaconda
Just so you are aware, it is possible to just install Jupyter Notebook on its own (but please don’t) when using
Python 3 (as we are), you can use a tool bundled with Python called pip to install Jupyter Notebook like
this:

$ pip install jupyter

However, we will use the most popular distribution of Python called Anaconda. Anaconda has its own
installer tool called Conda that you could use for installing a third-party package. However, Anaconda
comes with many scientific libraries preinstalled, including the Jupyter Notebook, MathPlotLib, Pandas,
NumPy, Scikit, etc., so you don’t actually need to do anything other than install Anaconda itself.

So go to Anaconda.com and download:


After downloading, install the software for an individual installation as we did with Python originally. Click
Next:

Agree to the license agreement:


Install the individual edition:

Install where prompted into the C: drive programs folder (different on pcs, laptops, etc.)

Make sure both of the following boxes are NOT TICKED and click Install:
After installation, you should see Completed! Click Next.

Click Next again:


Click Finish:
Launching Anaconda Navigator
After installation of Anaconda from your start menu, you can Click on Anaconda Navigator which opens a
browser type interface to the entire Anaconda suite of software. You will see that quite a few bits of
software launch in the background with Anaconda but that’s normal:

You may be prompted to update the Anaconda Navigator from time to time such as follows. Always click to
update. It may require you to exit the Navigator and reopen it again but it usually provides a launch button at
the end of the update:
Launching Jupyter Notebook
We wish to open up Jupyter Notebook.

As an alternative to going through the Anaconda Navigator, you can just click on Jupyter Notebook quick
launch button in the dropdown list under Anaconda in the start menu. You can also launch it from the
Anaconda Prompt by typing Jupyter notebook and pressing enter but this is rarely used:
Starting the Jupyter Notebook Server
Now that you have Jupyter Notebook opened, let’s learn how to use it. Irrespective of how you launch it,
Jupyter will start up in your default browser on the following URL: http://localhost:8888/tree. Localhost is
not a website, but it indicates that the content is being served from your local machine: your own computer
is the local host. Your browser should now look something like this:

Note that right now you are not actually running a Notebook, but instead you are just running the Notebook
Server. You will actually see what is currently running on the terminal when you start to create Notebooks.
For example:
Creating a Jupyter Notebook
The Jupyter Notebook is quite useful for sharing data. You can turn your Notebook into a slideshow or share
it online with GitHub. If you want to share a Notebook without requiring your users to install anything, you
can use binder for that. Google and Microsoft both have their own version of the Notebook that you can use
to create and share your Notebooks at Google Colaboratory and Microsoft Azure Notebooks respectively.
You can browse really interesting Notebooks there as well. Ctrl + click the links to view.

Project Jupyter recently launched their latest product, JupyterLab. JupyterLab incorporates Jupyter
Notebook into an Integrated Development type Editor that you run in your browser. You can kind of think
of JupyterLab as an advanced version of Jupyter Notebook. JupyterLab allows you to run terminals, text
editors and code consoles in your browser in addition to Notebooks.

Let’s create a Notebook now. Click on New, Python 3 (ipykernel).


The following shows what a new Jupyter Notebook looks like:

Naming the Notebook


You will notice that at the top of the page is the word Untitled. This is the title for the page and the name of
your Notebook. Since that isn’t a very descriptive name, let’s change it. Move your mouse over the
word Untitled and click on the text. You should now see an in-browser dialog titled Rename Notebook. Let’s
rename this one to Hello Jupyter:

Running Cells
A Notebook’s cell defaults to using code whenever you first create one, and that cell uses the kernel that you
chose when you started your Notebook. In this case, you started you chose Python 3 as your kernel, so that
means you can write Python code in your code cells. Since your initial Notebook has only one empty cell in
it, the Notebook can’t really do anything.

Thus, to verify that everything is working as it should, you can add some Python code to the cell and try
running its contents. Let’s try adding the following code to that cell:
Running a cell means that you will execute the cell’s contents. To execute a cell, you can just select the cell
and click the Run button that is in the middle of the row of buttons along the top or just press Shift + Enter
on the keyboard. The output should look like this:

If you have multiple cells in your Notebook, and you run the cells in order, you can share your variables and
imports across cells. This makes it easy to separate out your code into logical chunks without needing to
reimport libraries or recreate variables or functions in every cell.

When you run a cell, you will notice that there are some square braces next to the word In, on the left of the
cell. The square braces will auto fill with a number that indicates the order that you ran the cells. For
example, if you open a fresh Notebook and run the first cell at the top of the Notebook, the square braces
will fill with the number 1.

The Menus
The Jupyter Notebook has several menus that you can use to interact with your Notebook. The menu runs
along the top of the Notebook just like menus do in other applications. Here is a list of the menus:

 File  Cell
 Edit  Kernel
 View  Widgets
 Insert  Help

Let’s discuss the menus one by one. We can’t go into detail for every single option in every menu, so we
will focus on the items that are unique to the Notebook application.

File Menu
In the File Menu, you can create a new Notebook or open a pre-existing one. This is also where you would
go to rename a Notebook. The Save and Checkpoint option allows you to create checkpoints that you can
roll back to if you need to. Rolling back enables you to return your code to a previous state, perhaps one
where it was stable, before you did something you later decided was erroneous. Checkpoints and rollback
are common in programming.

Edit Menu
In the Edit Menu you can cut, copy, and paste cells. This is also where you can delete, split, or merge a cell.
You can reorder cells here too. Note that some of the items in this menu are greyed-out. The reason for this
is that they do not apply to the currently selected cell. For example, a code cell cannot have an image
inserted into it, but a Markdown cell can. If you see a greyed-out menu item, try changing the cell’s type and
see if the item becomes available to use.

The View Menu


This menu is useful for toggling the visibility of the header and toolbar. You can also toggle Line
Numbers within cells on or off. This is also where you can experiment with the cell’s toolbar.

The Insert Menu


This menu is just for inserting cells above or below the currently selected cell.

The Cell Menu


This menu allows you to run one cell, a group of cells, or all the cells. You can also go here to change a
cell’s type, although the toolbar is probably more intuitive for that. The other handy feature in this menu is
the ability to clear a cell’s output. If you are planning to share your Notebook with others, you will probably
want to clear the output first so that the next person can run the cells themselves.

The Kernel Menu


The Kernel cell is for working with the kernel that is running in the background. Here you can restart the
kernel, reconnect to it, shut it down, or even change which kernel your Notebook is using. You probably
won’t be working with the Kernel all that often, but there are times when you are debugging a Notebook that
you will find you need to restart the Kernel. When that happens, this is where you do it.

The Widgets Menu


This menu is for saving and clearing widget state. Widgets are basically JavaScript widgets that you can add
to your cells to make dynamic content using Python (or another Kernel).

The Help Menu


This menu is where you can learn about the Notebook’s keyboard shortcuts, a user interface tour, and lots of
reference material.
Adding Rich Content
Jupyter Notebook supports adding rich content to its cells. In this section, you will get an overview of just
some of the things you can do with your cells using Markup and Code. There are technically four cell types:
Code, Markdown, Raw NBConvert, and Heading.

The Heading cell type is no longer supported and will display a dialog that says as much. Instead, you are
supposed to use Markdown for your Headings.

The Raw NBConvert cell type is only intended for special use cases when using the nbconvert command
line tool. Basically, it allows you to control the formatting in a very specific way when converting from a
Notebook to another format. We will discuss again later.

The primary cell types that you will use are the Code and Markdown cell types. You have already learned
how code cells work, so let’s learn how to style your text with Markdown.

You might also like