This guide will help you installing Jupyter Notebook for programming in Python. We’ll explore the basic functionality of Jupyter Notebook and you’ll be able to try out the first examples.
From the very beginning, you’ll learn everything to need to know to use Python for our Data Analytics course.
Jupyter Notebook is a web application that allows you to create and share documents that contain:
- Live code (e.g. Python code)
- Explanatory Text (written in Markdown syntax)
Let’s get started and install Jupyter Notebook on your computer …
Setting Up Jupyter Notebook
The first step to get started is to visit the project’s website at https://www.jupyter.org
Here you’ll find two options:
- Try it in your browser
- Install the Notebook
In the first option, Try it in your browser you can access a hosted version of Jupyter Notebook. This will get you direct access without needing to install it on your computer.
The second option Install the Notebook will take you to another page that gives you detailed instructions for the installation. There are two different ways:
- Installing Jupyter Notebook by using the Python’s package manager pip
- Installing Jupyter Notebook by installing the Anaconda distribution
Especially if you’re new to Python and would like to set up your development environment from scratch using the Anaconda distribution is a great choice. If you follow the link (https://www.anaconda.com/download/) to the Anaconda download page you can choose between installers for Windows, macOS, and Linux.
Download and execute the installer of your choice. Having installed the Anaconda distribution, we can now start Jupyter Notebook by using the following command –
$ jupyter notebook
You’ll see the following response on the command line –
The web server is started, and the Jupyter Notebook application is opened in your default browser automatically. You should be able to see a browser output that is similar to the following screenshot.
As you can see the user interface of Jupyter Notebook is split up into three sections (tabs) –
The default view is the Files tab from where you can open or create notebooks.
Creating a new Jupyter Notebook
Creating a new Jupyter Notebook is easy. Just use the New dropdown menu and you’ll see the following options –
Select option Python 3 to open a new Jupyter Notebook for Python. The notebook is created, and you should be able to see something similar to the below screenshot.
The notebook is created but still untitled. By clicking into the text “Untitled” on the top you can give it a name. By giving it a name, the notebook will also be saved as a file of the same name with extension.ipynb. E.g. name the notebook code1.
Switching back to the Files tab you’ll be able to see a new file code1.ipynb
Because this notebook file is opened right now the file is marked with the status Running. From here you can decide to shut down this notebook by clicking on the button Shutdown.
However, before shutting down the notebook let’s switch back to the notebook view and try out a few things to get familiar with the notebook concept.
Working with the Notebook
The notebook itself consists of cells. A first empty cell is already available after having created the new notebook.
This cell is of type “Code” and you can start typing in Python code directly. Executing code in this cell can be done by either clicking on the run cell button or hitting Shift + Enter keys.
The resulting output becomes visible right underneath the cell.
Edit and Command Mode
If a cell is active two modes distinguished –
- edit mode
- command mode
If you just click in one cell the cell is opened in command mode which is indicated by a blue border on the left.
The edit mode is entered if you click into the code area of that cell. This mode is indicated by a green border on the left side of the cell.
If you’d like to leave edit mode and return to command mode again you just need to hit ESC.
To get an overview of functions that are available in command and edit mode, you can open up the overview of key shortcuts by using the menu entry Help → Keyboard Shortcuts.
Exporting the Notebook
Jupyter Notebook gives you several options to export your notebook. Those options can be found in menu File → Download as