Jupyter is a free and open-source web application for interactive computing and data science. Jupyter supports all programming languages and provides multiple software, such as JupyetrLab, which provides a feature-rich and tabbed multi-notebook editing environment, Notebook as a lightweight and simplified notebook authoring, Qtconsole, and many more.

In this guide, we’ll take you through the installation of JupyterLab on Debian 12 step-by-step. You will install JupyterLab on Python virtual environment, running JupyterLab as a systemd service, then you will install and set up Nginx as a reverse proxy for JupyterLab.

Prerequisites

Before commencing, confirm that you have the following:

  • A Debian 12 server.
  • A non-root user with administrator privileges.

Installing Dependencies

Jupyter is an ecosystem of free and open-source Python software for interactive computing across all programming languages. To install Jupyter, you must ensure that Python is installed on your system.

In this section, you will install package dependencies for Jupyter, which includes Python3, Pip package manager, Python venv virtual environment, and Node.js.

Before you begin, update and refresh your Debian package index using the following command.

sudo apt update

<img alt="update repo" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/1-update-repo.png651700a08949a.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="199" loading="lazy" src="data:image/svg xml,” width=”750″>

Now install dependencies by executing the following apt install command. With this, you will install Python3, Pip package manager, venv virtual environment management, and Node.js.

sudo apt install python3 python3-pip python3-venv nodejs

Type y to confirm and proceed with the installation.

<img alt="install deps" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/2-install-deps.png651700a0ae10e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="188" loading="lazy" src="data:image/svg xml,” width=”630″>

After dependencies are installed, execute the following command to check the version of each dependency, including Python3, Pip, and Node.js

python3 --version

pip3 --version

node --version

The output below shows you that Python 3.11, Pip 23, and Node.js 18.13 are installed.

<img alt="check python pip node.js" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/3-check-python3-pip3.png651700a0d97eb.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="191" loading="lazy" src="data:image/svg xml,” width=”613″>

Installing Jupyter

After installing dependencies, you will next install the Jupyter meta packages using the Python virtual environment on the Debian 12 machine. To achieve that, you must complete the following:

  • Creating a Python virtual environment
  • Installing Jupyter
  • Configuring JupyterLab

Let’s start.

Creating Python Virtual Environment

In this section, you will create a new Python virtual environment that will be used for Jupyter installation. With this scenario, you will have an isolated development environment that won’t affect your whole system. Also, you can recreate this as time goes on.

Log in to your non-root user using the following command.

su - user

Now create a new directory ~/project and move into it. Then, create a new virtual environment called venv using the following command. After executing the command, the new directory venv will be created.

mkdir -p ~/project; cd ~/project

python3 -m venv venv

Next, run the following command to activate the venv virtual environment. Once activated, your shell prompt will become like “(venv) user@hostname:#…“.

source venv/bin/activate

<img alt="create virtual environment python" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/4-create-virtual-environment.png651700a1159fc.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="176" loading="lazy" src="data:image/svg xml,” width=”502″>

Installing Jupyter

After creating a Python virtual environment. you will install the Jupyter package via Pip. The Jupyter package is a meta package of Jupyter ecosystems, which includes IPython, JupyterLab, Jupyter Server, Jupyter Notebook, qtconsole, and many more.

Execute the pip3 command below to install Jupyter to your Debian system.

pip3 install jupyter

During the installation, below is the output will be shown on your terminal:

<img alt="install jupyter" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/5-install-jupyter.png651700a15a5ea.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="551" loading="lazy" src="data:image/svg xml,” width=”750″>

After installation is finished, check the location of the Jupyter binary file and version using the following command.

which jupyter

jupyter --version

In the following output, you should see the Jupyter binary file is located within the venv directory. Also, you should see the version of the Jupyter package that is installed on your system.

<img alt="check jupyter" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/6-check-jupyter.png651700a18d8e6.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="433" loading="lazy" src="data:image/svg xml,” width=”466″>

Configuring JupyterLab

JupyterLab is the next-generation web-based user interface for the Jupyter ecosystem. With JupyterLab, you can work with documents, and activities such as Jupyter Notebook, text editor, and terminal in one window. The JupyterLab offers you an IDE-like experience for managing and developing Jupyter projects.

In this section, you will set up JupyterLab for your Jupyter project. But before that, you must configure the Jupyter Server first to secure your installation.

First, run the following command to generate the Jupyter Server config file and set up the password. Input your password and repeat.

jupyter server --generate-config

jupyter server password

After executing the command, the Jupyter Server configuration will be generated at ~/.jupyter/ directory.

<img alt="secure jupyter" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/7-secure-jpyter-password.png651700a1bcc36.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="190" loading="lazy" src="data:image/svg xml,” width=”750″>

You can verify the content of the Jupyter Server configuration using the following command.

jupyter server --show-config

The similar output below will be shown:

<img alt="jupyter server config" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/8-jupyter-server-config.png651700a2045e5.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="118" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, run the following command to generate a new configuration for JupyterLab. The JupyterLab configuration will be generated at the ~/.jupyter/ directory.

jupyter lab --generate-config

<img alt="generate jupyterlab config" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/9-generate-jupyterlab-config.png651700a23ab5a.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="136" loading="lazy" src="data:image/svg xml,” width=”735″>

After the configuration is generated, verify the JupyterLab configuration using the following command.

jupyter lab --show-config

Below is an example of JupyterLab configuration:

<img alt="verify jupyterlab config" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/10-jupyterlab-config.png651700a26e398.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="151" loading="lazy" src="data:image/svg xml,” width=”750″>

Now you can run JupyterLab installation using the following command. Be sure to change the IP address with your server IP address.

jupyter lab --ip 192.168.10.15

The JupyterLab will be running on your server IP address with default port 8888. The JupyterLab is accessible via URL path /lab.

<img alt="run jupyterlab" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/11-run-jupyterlab.png651700a2cb9bb.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="440" loading="lazy" src="data:image/svg xml,” width=”750″>

Open your web browser and visit your server iP address followed by port 8888 and path /lab, such as http://192.168.10.15:8888/lab. Input your Jupyter Server password and click Log in to continue.

<img alt="login jupyterlab" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/12-jupyterlab-login.png651700a2f3660.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="204" loading="lazy" src="data:image/svg xml,” width=”597″>

If you have the proper password, you should see the JupyterLab user dashboard like the following:

<img alt="jupyterlab dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/13-jupyterlab-dashboard.png651700a3768b8.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="460" loading="lazy" src="data:image/svg xml,” width=”750″>

You can now press Ctrl c twice to terminate the JupyterLab process.

Running JupyterLab as a Systemd Service

In the following step, you will create a new systemd service file that will be used to run JupyterLab. This way, your JupyterLab installation will be running in the background as a systemd service, and you can easily manage JupyterLab via the systemctl utility.

Create a new systemd service file /etc/systemd/system/jupyterlab.service using the following nano editor command.

sudo nano /etc/systemd/system/jupyterlab.service

Insert the following configuration and be sure to change username bob.

[Unit]

Description=JupyterLab Service

 

[Service]

Type=simple

PIDFile=/run/jupyter.pid

ExecStart=/home/bob/project/venv/bin/jupyter lab --config=/home/bob/.jupyter/jupyter_lab_config.py

User=bob

Group=bob

WorkingDirectory=/home/bob/project

Restart=always

RestartSec=10

 

[Install]

WantedBy=multi-user.target

When finished, save and close the file.

Now run the following systemctl command to reload the systemd manager and apply the changes.

sudo systemctl daemon-reload

Then, start and enable the jupyterlab service using the following command.

sudo systemctl start jupyterlab

sudo systemctl enable jupyterlab

<img alt="jupyterlab as a service" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/14-jupyterlab-as-service.png651700a39ec12.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="208" loading="lazy" src="data:image/svg xml,” width=”741″>

Lastly, verify the jupyterlab service to ensure that the service is running.

sudo systemctl status jupyterlab

The following output confirms that the jupyterlab service is running.

<img alt="checking jupyterlab service" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/15-check-jupyterlab.png651700a3d10c2.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="141" loading="lazy" src="data:image/svg xml,” width=”750″>

Configuring Nginx as a Reverse Proxy for Jupyter

In this guide, you will be running JupyterLab with Nginx as a reverse proxy. To achieve that, you must complete the following:

  • Allowing Remote Access to JupyterLab
  • Installing and Configuring Nginx as a Reverse Proxy

Allowing Remote Access to JupyterLab

By default, the JupyterLab installation is only accessible via a local IP address. To allow remote connection, you must modify the default JupyterLab configuration.

Open the JupyterLab configuration ~/.jupyter/jupyter_lab_config.py using the following nano editor command.

nano ~/.jupyter/jupyter_lab_config.py

Uncomment option c.ServerApp.allow_remote_access and change the value to True. This will make JupyterLab accessible from a remote connection, which includes running JupyterLab behind a reverse proxy.

c.ServerApp.allow_remote_access = True

Save the file and exit the editor when you’re done.

Now run the following systemctl command to restart the jupyterlab service and apply the changes.

sudo systemctl restart jupyterlab

Then, verify the jupyterlab service using the following command.

sudo systemctl status jupyterlab

At the bottom output, you should see the generated token for accessing your JupyterLab installation, and be sure to copy it for the next section.

<img alt="show token" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/18-show-token.png651700a411a59.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="108" loading="lazy" src="data:image/svg xml,” width=”750″>

Installing and Configuring Nginx as a Reverse Proxy

After allowing remote access to JupyterLab, you will next install Nginx and configure it as a reverse proxy for your JupyterLab installation.

Install Nginx by executing the apt install command below.

sudo apt install nginx -y

Below is the output during the Nginx installation.

<img alt="install nginx" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/16-install-nginx.png651700a43ebc0.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="282" loading="lazy" src="data:image/svg xml,” width=”631″>

After Nginx is installed, create a new server block configuration /etc/nginx/sites-available/jupyterlab using the following nano editor.

sudo nano /etc/nginx/sites-available/jupyterlab

Insert the following configuration and be sure to change the domain name within the server_name option.

server {

    listen 80;

    server_name jupyterlab.hwdomain.io;

    

    access_log /var/log/nginx/hwdomain.io.access.log;

    error_log /var/log/nginx/hwdomain.io.error.log;

 

    location / {

        proxy_pass http://127.0.0.1:8888;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_set_header X-Real-IP $remote_addr;

        proxy_set_header Host $http_host;

        proxy_http_version 1.1;

        proxy_redirect off;

        proxy_buffering off;

        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "upgrade";

        proxy_read_timeout 86400;

    }

}

Save and exit the file when finished.

Now run the following command to activate the server block file /etc/nginx/sites-available/jupyterlab and verify the Nginx configuration.

sudo ln -s /etc/nginx/sites-available/jupyterlab /etc/nginx/sites-enabled/

sudo nginx -t

If you’ve proper Nginx syntax, you should get the output “syntax is ok – test is successful“.

<img alt="setup nginx reverse proxy" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/17-nginx-reverse-proxy-jupyterlab.png651700a46a85a.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="205" loading="lazy" src="data:image/svg xml,” width=”750″>

Lastly, run the systemctl command below to restart the nginx service and apply the changes. Then, verify it to ensure that the service is running.

sudo systemctl restart nginx

sudo systemctl status nginx

If Nginx is running, you should get the output active (running).

Access JupyterLab Installation via Local Machine

To access JupyterLab via domain name, you can utilize the /etc/hosts file for Linux clients or C:WindowsSystem32driversetchosts file for Windows users.

Open the /etc/hosts file on your Linux client using the nano editor.

sudo nano /etc/hosts

Insert the following configuration into the file and be sure to change the IP address and the domain name with your information.

192.168.10.15   jupyterlab.hwdomain.io

Save and exit the file when you’re done.

Next, open your web browser and visit the domain name of your JupyterLab installation, such as http://jupyterlab.hwdomain.io. If your installation is successful, you should get the JupyterLab login page.

At the bottom page, input the generated and the new password for your JupyterLab installation. Then click the button Log in and set a new password.

<img alt="setup password" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/19-setup-password.png651700a497c51.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="375" loading="lazy" src="data:image/svg xml,” width=”693″>

If everything goes well, you should be redirected to the JupyterLab dashboard like the following.

<img alt="jupyterlab dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/13-jupyterlab-dashboard.png651700a3768b8.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="460" loading="lazy" src="data:image/svg xml,” width=”750″>

With this, your JupyterLab installation is complete.

Conclusion

By completing this step-by-step guide, you have accomplished the installation of JupyterLab on the Debian 12 server. You’ve installed JupyterLab using Python virtual environment, running JupyterLab in the background as a systemd service, and configured Nginx as a reverse proxy for JupyterLab. Now you can create and manage your Jupyter Project.