How to install Jupyter Notebook on Ubuntu Linux.

Our plan today

We’re going to go through the steps to get Jupyter Notebook installed and running from scratch Ubuntu or Debian.

What we’ll cover

  1. Install Python
  2. Create Python Virtual Environment
  3. Install Jupyter
  4. Run Jupyter Notebook
  5. Create Jupyter in application menu in XFCE

I’m using Ubuntu 20.04, but this will be the same steps for Ubuntu 21.10, 20.04, 18.04 and 16.04. Also should work entirely for recent versions of Debian too.

1. Install Python

First off lets make sure that Ubuntu is all up to date, by running the following:

sudo apt-get update && sudo apt-get upgrade

Now we need to install python and pip with the following:

sudo apt install python3-pip python3-dev

Upgrade pip and install the package by typing:

What is pip? why do we need it?

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

2. Create Python Virtual Environment

Create a directory to put our virtual environment

mkdir code

Create Python Virtual Environment

Here we are going into our code directory and creating a new Virtual Environment called jupyterenvironment. Go ahead and name your environment to something you want.

cd code
virtualenv jupyterenvironment 

Load created Virtual Environment

Now we actually need to load the virtual environment, you can do that by running source and in the bin/activate folder

source jupyterenvironment/bin/activate 

3. Install Jupyter

Now we can actually install juypter using pip.

Run the following command:

pip install jupyter

Install nbconvert

pip install nbconvert

Run Jupyter Notebook

Now we can actually run jupyter notebook.

jupyter notebook

4. Output to PDF

Install pandoc & Latex to allow for PDF export

To allow us to export our reports to PDF we are going to install pandoc and Latex

sudo apt-get install pandoc
sudo apt-get install texlive-xetex texlive-fonts-recommended

5. Create Jupyter in application menu for XFCE

Create script to run jupyter

Create a file called run-jupyter.sh

#!/bin/bash

source /home/username/jupyterenvironment/bin/activate
jupyter notebook

Create applications menu item in XFCE

Create a file in /usr/share/applications called jupyter.desktop

[Desktop Entry]
Name=Jupyter Notebook
Exec=/home/username/jupyterenvironment/run-jupyter.sh
Type=Application
Terminal=true