In this tutorial we are going to see how to install Jupyter lab. More on this tool here:

Install NodeJS

We are going to install NVM (Node Version Manager) to manage the install NodeJS version.

sudo apt-get update
sudo apt-get install -y curl
curl -o- | bash

Add the following commands in your ~/.zshrc file:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Once it is done do not forget to reload your terminal with source ~/.zshrc.

Then install the lastest LTS NodeJS version:

nvm ls-remote
# Determine the latest LTS. For me it is v10.16.0 when I am writing this tutorial
nvm install v10.16.0
nvm use default v10.16.0

Install python 3

sudo apt-get update
sudo apt-get install python3
sudo apt-get install python3-pip

Install jupyterlab

pip3 install jupyterlab

If you are using ohmyzsh (and you should !) edit your ~/.zshrc file and add the line at the end export PATH=$PATH:~/.local/bin/. Then execute source ~/.zshrc.

Verify jupyterlab works

jupyter lab --allow-root --ip= --no-browser

Install extensions hub

Kill the previously launched server with Ctrl-c

jupyter labextension install @jupyterlab/hub-extension
jupyter lab build
jupyter lab --allow-root --ip= --no-browser

Go to “Settings” –> “Enable Extensions manager (Experimental) to enable the extensions manager. If you click on the extensions icon that appear on the left menu you should see all available extensions to install.

Make Jupyterlab a service

Generate a config file:

jupyter-lab --generate-config

Create a working directory:

mkdir -p /home/$USER/Dev/jupyterlab
export WorkingDirectory=/home/$USER/Dev/jupyterlab

Generate Service file:

cat << EOF | sudo tee /etc/systemd/system/jupyter-lab.service
Description=Jupyter Lab
ExecStart=/home/$USER/.local/bin/jupyter-lab --config=/home/$USER/.jupyter/

Reload systemctl daemon after creating service entry:

sudo systemctl daemon-reload

Enable Jupyter Lab service:

sudo systemctl enable jupyter-lab.service

Start the service:

sudo systemctl start jupyter-lab.service

Verify jupyterlab service is working and get access token:

sudo systemctl status jupyter-lab.service

Add custom Password

Start a Python repl and enter the following commands:

from notebook.auth import passwd

Copy the hashed password, uncomment the line c.NotebookApp.password and add the password as value.

Restart the service (or container).

Custom jupyter conf

It is possible to custom jupyter lab conf with the following commands:

# Incoming connection whitelist. tried with IP & CIDR. not sure about ranges. should be comma separated if more than one.
sed -i.back "s/#c.NotebookApp.allow_origin = ''/c.NotebookApp.allow_origin = '\/24'/" ~/.jupyter/

# Jupyter listening IP. Set to localhost if only planning on using locally.
sed -i "s/#c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '$ipAddress'/" ~/.jupyter/

# Whether or not to open browser on jupyter launch. If headless, or server, set to False.
sed -i "s/#c.NotebookApp.open_browser = True/c.NotebookApp.open_browser = False/" ~/.jupyter/

# Listening port. Change if necessary
sed -i "s/#c.NotebookApp.port = 8888/c.NotebookApp.port = 8888/" ~/.jupyter/

# Randomly generated token for access without user/pass
sed -i "s/^#c.NotebookApp.token .*/c.NotebookApp.token = '$token'/" ~/.jupyter/

# Trash Cleanup
sed -i "s/#c.NotebookApp.cookie_secret = b''/#c.NotebookApp.cookie_secret = ''/" ~/.jupyter/
sed -i "s/#c.Session.key = b''/#c.Session.key = ''/" ~/.jupyter/
sed -i "s/#c.NotebookNotary.secret = b''/#c.NotebookNotary.secret = ''/" ~/.jupyter/

Have fun !