| by Arround The Web | No comments

How to Install the Littlest JupyterHub (TLJH) on Debain 11/12 and Ubuntu 20.04 LTS/22.04 LTS

The Littlest Jupyter Hub (TLJH) is a Jupyter Hub distribution. The main goal of this project is to make it easy to set up Jupyter Hub for a small number of users (100 users at most) on a single server. TLJH allows the users to use Jupyter Lab in their own isolated environment.

In this article, we will show you how to install The Littlest Jupyter Hub (TLJH) on Debian 11, Debian 12, Ubuntu 20.04 LTS, and Ubuntu 22.04 LTS operating systems. We will also show you how to access Jupyter Hub, create new TLJH users, and manage the TLJH user sessions. We will show you how to install the new Python libraries for all TLJH users as well.

Topic of Contents:

  1. Installing the Dependency Packages for TLJH
  2. Installing The Littlest Jupyter Hub (TLJH)
  3. Checking If TLJH Is Working
  4. Accessing TLJH
  5. Creating TLJH Users and Managing the TLJH User Sessions
  6. Installing Python Libraries for All Jupyter Hub Users
  7. Conclusion
  8. References

Installing the Dependency Packages for TLJH

First, update the APT package database cache with the following command:

$ sudo apt update

To install the required dependency packages for Jupyter Hub, run the following command:

$ sudo apt install python3 python3-dev python3-pip git curl

To confirm the installation, press “Y” and then press <Enter>.

The dependency packages are being downloaded. It takes a while to complete.

The dependency packages are being downloaded. It takes a while to complete.

The dependency packages should be installed on your Ubuntu/Debian machine at this point.

Installing The Littlest Jupyter Hub (TLJH)

Before you install TLJH on your Ubuntu/Debian machine, you have to find the username of the user that you want to configure as a TLJH administrator. Usually, you will configure the login user of your Ubuntu/Debian machine as a TLJH administrator unless you have something else in mind. You can configure any user as TLJH administrator depending on your requirements.

You can find the username of your login user with the following command:

$ whoami

In our case, the login user name is “shovon”.

To install TLJH on your Ubuntu/Debian machine, run the following command:

$ curl -L https://tljh.jupyter.org/bootstrap.py | sudo -E python3 - --admin $(whoami)

NOTE: We are configuring our login user as TLJH administrator. If you want to configure some other user as TLJH administrator, replace –admin $(whoami) with –admin in the previous command.

TLJH is being installed on your Ubuntu/Debian machine. It takes a while to download and install all the TLJH components.

At this point, TLJH should be installed on your Ubuntu/Debian machine.

Checking If TLJH Is Working

To verify that TLJH is working on your computer, check first whether the TLJH proxy service traefik is working with the following command:

$ sudo systemctl status traefik.service

As you can see, the traefik proxy service is running and it’s configured to automatically start on system boot.

Also, check whether the JupyterHub service is working with the following command:

$ sudo systemctl status jupyterhub.service

As you can see, the JupyterHub service is also running and it’s configured to automatically start on system boot.

As the traefik proxy and JupyterHub “systemd” services are running correctly, The Littelest Jupyter Hub (TLJH) is working just fine.

Accessing TLJH

To access TLJH from a web browser, you need to know the IP address (or DNS name if configured) of your Ubuntu/Debian machine. In our case, the IP address is 192.168.189.128. It might be different for you. So, make sure to replace it with yours from now on.

$ ip a

Open a web browser app and visit http://192.168.189.128 and you will see the JupyterHub login page.

Type in your admin username, your desired login password (that you want to set for the admin user of JupyterHub), and click on “Sign in”.

You should be logged in to JupyterHub.

Creating TLJH Users and Managing the TLJH User Sessions

To create new TLJH users, log in to JupyterHub as the admin user and click on File > Hub Control Panel.

Click on “Admin”.

All the TLJH users and user sessions/hubs should be listed.

Click on “Add Users”.

Type in the usernames that you want to add to TLJH[1]. You can add a single user or multiple users to TLJH at once. To add multiple users to TLJH, type in each username in a separate line.

If you want the newly created users to have administrative access to TLJH, tick on “Admin”[2].

Once you’re done, click on “Add Users”[3].

The new TLJH users should be created[1].

From the “Admin” page, you can manage (Start/Stop) the TLJH user sessions/hubs for each user[2] and all users[3].

To log in as one of the TLJH users, type in the username and the password that you want to set for the new user and click on “Sign in”.

NOTE: The password that you use to log in for the first time will be set as the login password for the new user.

You should be logged in to JupyterHub as the new user.

The TLJH admin user can see the users who are logged in to TLJH and manage the user sessions/hub.

Installing the Python Libraries for All Jupyter Hub Users

Each TLJH user can install any Python libraries with Python PIP from their Jupyter Hub session. But to save the disk space, you can install the most commonly used Python libraries system-wide so that all Jupyter Hub users can access them without needing to reinstall them.

First, log in to TLJH as the admin user and click on “Terminal” from the “Launcher” tab.

To install the matplotlib Python library (let’s say) for all TLJH users, run the following command:

$ sudo -E pip3 install matplotlib

Matplotlib is being installed. It takes a while to complete.

At this point, the matplotlib Python library should be installed for all TLJH users.

To check whether other TLJH users can use the matplotlib Python library, login as one of the TLJH users, create a new Jupyter Notebook, and run the following lines of codes (that we copied from the matplotlib documentation):

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()

If the TLJH user can access matplotlib, the code should generate a graph as shown in the following screenshot:

Conclusion

In this article, we showed you how to install The Littlest Jupyter Hub (TLJH) on Debian 11, Debian 12, Ubuntu 20.04 LTS, and Ubuntu 22.04 LTS operating systems. We also showed you how to access TLJH from a web browser, create new TLJH users, and manage the TLJH user sessions. We showed you how to install the new Python libraries for all TLJH users as well.

References:

Share Button

Source: linuxhint.com

Leave a Reply