How to Install Jupyter Notebook on Ubuntu 22.04

Jupyter Notebook is an open-source server-client application written in Python. The word “Jupyter” comes from the languages that support this platform: Julia (Ju), Python(py), and R (er).

The Jupyter App can be executed on a local desktop or on a remote server. This blog post will focus on installing the software on a Linux server.

In this tutorial, we are going to show you how to install Jupyter Notebook on Ubuntu 22.04 OS. Let’s get started!

Prerequisites

  • A server with Ubuntu 22.04 as OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

Before we start with the installation, we need to update the system packages to the latest versions available.

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

Step 2. Install Python3

Since Jupyter Notebook is written in Python, we need to install Python3 and its extensions. To do that, execute the following commands:

sudo apt install python3 python3-pip python3-venv -y

After installation, you can check the installed version of Python with the following command:

python3 -V

You should receive the following output:

root@host:~# python3 -V
Python 3.10.6

Step 3. Create Python Virtual Environment

Now, when Python3 is installed, we are ready to create a virtual environment for our Jupyter Notebook application. To do that, follow the commands below:

cd /opt

python3.10 -m venv jupyter-venv

Once the virtual environment is created, we need to activate it with the following command:

source jupyter-venv/bin/activate

After the activation, the command prompt should look like this:

root@host:/opt# source jupyter-venv/bin/activate
(jupyter-venv) root@host:/opt#

Let’s move to the last step of this tutorial, about installing the Jupyter Notebook in the virtual environment.

Step 4. Install Jupyter Notebook

We are already in the virtual environment from the previous step:

(jupyter-venv) root@host:/opt#

The Jupyter Notebook can be installed with the pip3 command. The pip3 command will download the jupyter files and will install the required requirements for it.

Execute the following command to upgrade the pip3 before installing Jupyter Notebook.

pip install --upgrade pip

The output should look like this:

(jupyter-venv) root@host:/opt# pip install --upgrade pip
Requirement already satisfied: pip in ./jupyter-venv/lib/python3.10/site-packages (22.0.2)
Collecting pip
  Downloading pip-23.1.2-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 4.8 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.0.2
    Uninstalling pip-22.0.2:
      Successfully uninstalled pip-22.0.2
Successfully installed pip-23.1.2

Now, we are ready to install Jupyter with the command below:

pip3 install jupyter

After some time, you will see the following output:

Successfully installed Send2Trash-1.8.2 anyio-3.7.0 argon2-cffi-21.3.0 argon2-cffi-bindings-21.2.0 arrow-1.2.3 asttokens-2.2.1 attrs-23.1.0 backcall-0.2.0 beautifulsoup4-4.12.2 bleach-6.0.0 cffi-1.15.1 comm-0.1.3 debugpy-1.6.7 decorator-5.1.1 defusedxml-0.7.1 exceptiongroup-1.1.1 executing-1.2.0 fastjsonschema-2.17.1 fqdn-1.5.1 idna-3.4 ipykernel-6.23.1 ipython-8.14.0 ipython-genutils-0.2.0 ipywidgets-8.0.6 isoduration-20.11.0 jedi-0.18.2 jinja2-3.1.2 jsonpointer-2.3 jsonschema-4.17.3 jupyter-1.0.0 jupyter-client-8.2.0 jupyter-console-6.6.3 jupyter-core-5.3.0 jupyter-events-0.6.3 jupyter-server-2.6.0 jupyter-server-terminals-0.4.4 jupyterlab-pygments-0.2.2 jupyterlab-widgets-3.0.7 markupsafe-2.1.3 matplotlib-inline-0.1.6 mistune-2.0.5 nbclassic-1.0.0 nbclient-0.8.0 nbconvert-7.4.0 nbformat-5.9.0 nest-asyncio-1.5.6 notebook-6.5.4 notebook-shim-0.2.3 overrides-7.3.1 packaging-23.1 pandocfilters-1.5.0 parso-0.8.3 pexpect-4.8.0 pickleshare-0.7.5 platformdirs-3.5.1 prometheus-client-0.17.0 prompt-toolkit-3.0.38 psutil-5.9.5 ptyprocess-0.7.0 pure-eval-0.2.2 pycparser-2.21 pygments-2.15.1 pyrsistent-0.19.3 python-dateutil-2.8.2 python-json-logger-2.0.7 pyyaml-6.0 pyzmq-25.1.0 qtconsole-5.4.3 qtpy-2.3.1 rfc3339-validator-0.1.4 rfc3986-validator-0.1.1 six-1.16.0 sniffio-1.3.0 soupsieve-2.4.1 stack-data-0.6.2 terminado-0.17.1 tinycss2-1.2.1 tornado-6.3.2 traitlets-5.9.0 uri-template-1.2.0 wcwidth-0.2.6 webcolors-1.13 webencodings-0.5.1 websocket-client-1.5.2 widgetsnbextension-4.0.7

Now, we need to generate a config file for Jupyter Notebook settings with the following command:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
jupyter notebook --generate-config

The configuration will be created at /root/.jupyter/jupyter_notebook_config.py

(jypyter-venv) root@host:/opt# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py

Open the file, uncomment the following settings and set your IP address:

c.NotebookApp.ip = 'YourServerIPAddress'
c.NotebookApp.open_browser = True

After this, we can execute the last command to make Jupyter Notebook accessible in the browser.

jupyter notebook

You should see the following output:

jypyter-venv) root@host:/opt/jypyter-venv# jupyter notebook

  _   _          _      _
 | | | |_ __  __| |__ _| |_ ___
 | |_| | '_ \/ _` / _` |  _/ -_)
  \___/| .__/\__,_\__,_|\__\___|
       |_|

Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.

[I 16:39:53.927 NotebookApp] Serving notebooks from local directory: /opt/jypyter-venv
[I 16:39:53.927 NotebookApp] Jupyter Notebook 6.5.4 is running at:
[I 16:39:53.927 NotebookApp] http://YourIPAddress:8888/?token=01578a58fd2f7f08200177d08f41d31b91660feaa623455d
[I 16:39:53.928 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

Now, you can access the Jupyter Notebook on port 8888 with your IP address at http://YourIPAddress:8888.

That was all. You successfully installed Jupyter Notebook on Ubuntu 22.04. If you finding any difficulties while installing this software, you can sign up for one of our NVMe VPS plans and submit a support ticket. Our admins are available 24/7 and will start work on your request immediately. Always trust our epic support.

If you liked this post on how to install Jupyter Notebook on Ubuntu 22.04, please share it with your friends on social networks or simply leave a reply below. Thanks.

Leave a Comment