Install Jupyter Notebook for Python 2.7

Install Jupyter Notebook in Ubuntu 20.04 and later

Open the terminal and type:

sudo apt install jupyter-notebook jupyter  

Install Jupyter Notebook in Ubuntu 18.04-19.10

Open the terminal and type:

sudo apt install python3-notebook jupyter jupyter-core python-ipykernel  

To start the notebook server run the following command:

jupyter notebook

You should see Jupyter Notebook open in your web browser.

Install Jupyter Notebook in Ubuntu 14.04→16.10

The default version of Python in Ubuntu works OK, but pip needs to be updated to the latest version.

sudo apt-get update
sudo apt-get -y install python-pip python-dev
sudo -H pip install --upgrade pip
sudo apt-get -y install ipython ipython-notebook
pip install --user jupyter

If you are using Python 3.x, run these commands instead:

sudo apt-get update
sudo apt-get -y install python3-pip python3-dev
sudo -H pip3 install --upgrade pip
sudo apt-get -y install ipython3 ipython3-notebook
pip3 install --user jupyter

To start Jupyter Notebook, run the following command:

jupyter notebook  

If you also have python-matplotlib installed, the first line of code to enable plotting in the current Notebook is %matplotlib inline

It is possible to use Python 3 in Jupyter Notebook for Python 2 by adding the kernel for Python 2. If you're running Jupyter on Python 3, you can set up a Python 2 kernel like this:

python2 -m pip install ipykernel
python2 -m ipykernel install --user  

Install Jupyter Notebook in Ubuntu 17.04 and 17.10

In Ubuntu 17.04 and later Jupyter Notebook is available in the default Ubuntu repositories and can be quickly and easily installed using apt. Open the terminal and type:

sudo apt install jupyter-notebook jupyter-core python-ipykernel 

python-ipykernel is necessary for running Python 2.x programs in Jupyter Notebook, which otherwise supports only Python 3.x.

To start the notebook server run the following command:

jupyter notebook

You should see Jupyter Notebook open in your web browser.