What is Jupyter Notebook?

The Jupyter notebook is a web-based notebook environment for interactive computing.

Installing Jupyter Notebook in Ubuntu 20.04

To install Jupyter, first, we need to install pip3, which is a Python Package Installer. For this, update all of the installed packages using the update command:

  • sudo apt update

Use the following command to install pip3:

  • sudo apt install python3-pip

As Pip3 is already installed on my system, we’ll move forward towards the pip upgrade command:

  • sudo -H pip3 install --upgrade pip

Install Jupyter Notebook

  • pip3 install jupyter

To set password for jupyter

  • jupyter notebook password

To acccess Jupyter notebook form local network

  • jupyter notebook --ip 0.0.0.0 --port 8888

Running as service

Lets create a directory first to save notes on all in one place

mkdir JupyterNotebook
cd JupyterNotebook
pwd
/home/user/JupyterNotebook

Lets create a service script

touch jupyternotebook.service

lets find the path of jupyter-notebook

$ which jupyter-notebook
$ /usr/local/bin/jupyter-notebook
$ vim ./jupyternotebook.service
[Unit]
Description=Jupyter-Notebook Daemon

[Service]
Type=simple
ExecStart=/bin/bash -c "/usr/local/bin/jupyter-notebook  --allow-root --ip 0.0.0.0 --port 8888 --notebook-dir=/home/user/JupyterNotebook"
WorkingDirectory=/home/user
User=user
Group=user
PIDFile=/run/jupyter-notebook.pid
Restart=on-failure
RestartSec=60s

[Install]
WantedBy=multi-user.target
save and quit
  • copy the service to /etc/systemd/system/

Reload deamon Enable and start service

sudo cp jupyternotebook.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now jupyternotebook.service