How to Install Jupyter Notebook on Ubuntu 20.04

Today I’ll walk you through the steps to Install Jupyter Notebook on Ubuntu 20.04 and Set it up. This will be a Step by Step installation Tutorial for Jupyter Notebook on Ubuntu.

What is Jupyter Notebook –  Jupyter Notebook is a web-based computing platform and is an open-source project. It is primarily used for data processing, interactive computing projects, and scientific data visualization applications, and for sharing documents with code, visualizations, equations, etc.

Upgrade and Update

Before you download and install Jupyter Notebook, you’ll need to first update the index packages of your ubuntu system and upgrade the system packages using the command – 

sudo apt-get update
sudo apt-get upgrade

To Install Jupyter Notebook you’ll need root permissions to your ubuntu system, so make sure that you have root permissions.

Install Jupyter Notebook using Anaconda

If you have Anaconda installed on your Ubuntu then you can easily install Jupyter Notebook using just one line of command, before that first start anaconda to be able to use the conda command in the terminal. 

If you don’t have Anaconda installed then check this post out on Installing Anaconda on Ubuntu 20.04. In that post, I have shown you the full installation tutorial of anaconda.

Now once you have started anaconda, open the terminal window and there enter the following command to install Jupyter Notebook. 

conda install -c conda-forge notebook

After Jupyter Notebook finishes installing, you can run it using the command – 

jupyter notebook

Now, if you don’t have Anaconda installed then you can download the Jupyter Notebook using Pip3

Install Jupyter Notebook without Anaconda

To install Jupyter Notebook without Anaconda you will have to first install python3, ipython3 and pip3.

Install Python3, iPython, Pip3

First, open your terminal and in the terminal type the command given below to install Python3

sudo apt-get install python3

After that install ipython3 using this command – 

sudo apt-get install ipython3

After that install pip3 using the command  – 

sudo apt-get -y install python3-pip

After all these packages are installed in your ubuntu, update your index packages once again by using the command –

sudo apt-get update

Install Jupyter Notebook

Now after installing all the required packages you can now install the Jupyter notebook. To Install Jupyter, first go into root using the command – 

sudo su

After that use the command given below to install Jupyter Notebook using pip3.

pip3 install jupyter

It will take some time for the jupyter notebook to finish installing, once it is installed exit root by typing “exit” in terminal. After that you can run the jupyter notebook using the command –

jupyter notebook --allow-root

After the first startup and shutdown of Jupyter Notebook, you can use the command “jupyter notebook” to run Jupyter in new terminal windows.

Open Jupyter Notebook Dashboard

After typing the command to run jupyter, you will see an output in the terminal window where you entered the command, the output will give you a URL address that you will need to copy and open in your web browser to access the Jupyter Notebook dashboard.

Jupyter notebook local web address

This URL will have a token with it for the first time login, after that you can access Jupyter Notebook by going to the default address of Jupyter Notebook which is “http://localhost:8888”.

Change Jupyter Notebook port

Okay, so after you have installed Jupyter notebook, if you don’t want to run Jupyter Notebook on its default web address at http:localhost:8888 then you can change it using the command –

jupyter notebook --port port_number

Here in place of “port_number” use the port number that you want the Jupyter Notebook to use, like “http:localhost:9999”, or something else. Before entering this command in the terminal first close Jupyter Notebook using “CTRL + C”, enter y then press enter.

Fix Permission Denied when opening Jupyter Notebook

Now after installing Jupyter Notebook if you are facing any error like “Permission Denied” when trying to open jupyter notebook or when trying to create a new notebook then here’s how you can fix it.

Open your terminal and type the following commands –

sudo jupyter notebook --allow-root
sudo chmod -R 700 .local

This will fix the Permission denied problem, alternatively, you can also create a dedicated folder for Jupyter Notebook by using the following commands – 

mkdir folder_name
jupyter-notebook --notebook-dir folder_name

This will change the directory that Jupyter uses by default to the one that you created and selected. If you use this method then you will have no problem with permissions. 

Fix Jupyter Notebook not Opening

If your Jupyter Notebook is not opening then it’s probably happening due to corrupt files, to fix the problem all you will need to do is uninstall the Jupyter Notebook and all related files to it from your ubuntu system.

After that install it again and this time Jupyter Notebook should work fine. Use the command “conda uninstall pyzmq” to remove all jupyter related packages and after that reinstall all the Jupyter packages using “conda install pyzmq”.

And that’s it, that’s how you can install Jupyter Notebook on your Ubuntu 20.04 system. This tutorial also works on ubuntu 18.04.

[lyte id=’NMgIv9wgze0′ /]

Recent Content