How to install Jupyter on an Ubuntu Linux VM?

Overview

Jupyter Notebook is widely used for creating and sharing computational documents. It is a web-application, Jupyter supports 40+ languages like Python, Julia, R etc.

In this tutorial, we will cover the installation of Jupyter notebook on Ubuntu Linux OS.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • Knowledge of Linux commands

  • Good command over OpenStack security groups (OSSG)

  • Minimum system requirements (2 GB RAM, 20 GB Storage, 4-core CPU)

Get Started

Before we get into the nitty-gritty of the installation process, you should first have the OpenStack instance created. Click here to read the instructions on how to create an OpenStack instance.

Once done, follow the steps given below for installing Jupyter notebook on an Ubuntu system.

1) Upgrade and Update Packages

Before starting the installation, you need to ensure that the system is up-to-date. You can check that by running the Update command which will update APT list of packages and also the versions. Also, you need to execute upgrade command to install the latest packages.

sudo apt update && sudo apt -y upgrade 

2) Building Python Dependencies

Now, we install pip, Python 3 plus other required packages for building Python dependencies which help in avoiding errors by providing vital software components.

Here's the command for installing Python:

sudo apt install python3-pip python3-dev

3) Installing python using Python virtualenv

Upgrade the pip version to fetch the latest version of the package manager. Post that, install Python using virtualenv package, which allows you to manage Python packages for several projects and avoids installing packages globally which may break other projects or system tools.

sudo -H pip3 install --upgrade pip 
sudo -H pip3 install virtualenv

In this command, -H is used for security policy to set the “HOME” environment variable and store the file in home directory.

4) Creating a Virtual Environment for Python

Creating a Python virtual environment is important to prevent installing the packages globally in order to not break other projects or system tools. For this,

  1. Make a directory in home directory (or other location if you wish to do so). The new directory is our code directory. To make a new directory type the following command:

    mkdir jupyternb ​

  2. Then go to the directory andthen make a Python virtual environment called jptrenv.

    cd jupyternb
    virtualenv jptrenv 

  3. Now, we have to load and activate the virtual environment using the following command.

    source jptrenv/bin/activate​

5) Installing the Jupyter Notebook

Enter the below command in your system’s terminal to install Jupyter n/b using pip.

pip install jupyter

6) Create a rule in OpenStack security group

Next step is to create a rule in OpenStack security group. This step is necessary to allow Jupyter to access your web browser in order to function properly. To create a rule in OpenStack security group, follow the below given steps:

  1. Go to the Security group assigned to your instance

  2. Click create new rule top-right corner

  3. Enter the port number and IP details as shown

  4. Click create rule

7) Running the Jupyter Notebook

Once you have installed all required packages and dependencies, it's time to run the Notebook. Execute the below stated command:

jupyter notebook

This command opens Jupyter's homepage. You may choose Python3 by clicking on the new menu, or you can choose another choice, such as Terminal, Text File, or Folder, based on your choice. It will open a new Jupyter page in your browser.

Last updated