Skip to main content

How to install JupyterLab on Linux

Make your code extremely versatile with JupyterLab, a server-client application for interactive coding in Python, Julia, R, and more.
Image
Galaxy illustration

Photo by Adam Krypel from Pexels

The tech space is inundated with discussions about machine learning ops (MLOps), strict data regulations, and adherence to complex data pipelines. It's sometimes easy to forget that whimsically playing with code snippets, libraries, and data sets is essential to the success of data science projects. In fact, data exploration and feature engineering can take as much time as model development, if not more.

Before Jupyter Notebooks, data scientists wrote long (usually messy) scripts specifically for data exploration and transformation. Perhaps one function in the script was responsible for pumping out descriptive statistics on a data set, while another performed different transformations and plotted the new distribution.

Every time someone wanted a specific plot or statistic, the data scientist ran the entire script and modified function calls as needed. However, if the code was not neatly organized into functions, the data scientist ran the whole script and watched helplessly as multiple plots were generated onscreen.

Enter JupyterLab, a server-client application for interactive coding in Python, Julia, R, and more. JupyterLab provides an environment for developers to create Jupyter Notebooks and scripts. The notebooks are a solution for running organized code snippets (or cells) that operate independently of each other and whose output appears directly below the cell.

This guide demonstrates how to install, execute, and update JupyterLab on Red Hat Enterprise Linux (RHEL), CentOS Stream, or Fedora.

Choose a language

Before installing JupyterLab, you must decide on the programming language you intend to use and whether your workloads require graphics processing units (GPUs). JupyterLab supports over 100 programming languages, including Scala, Matlab, and Java.

[ Download now: A sysadmin's guide to Bash scripting. ]

Because Python is popular among data scientists, sysadmins, and power users alike, I'll use it in this article for demonstration.

Install JupyterLab

JupyterLab requires Python 3.3 or greater. Python's designated package manager, pip, makes it easy to install JupyterLab. Begin with dnf:

$ sudo dnf update
$ sudo dnf install epel-release
$ sudo dnf install python3
$ sudo dnf install python3-pip

After installation, verify that Python and pip are accessible:

$ python3 –version
$ python3 -m pip install --user --upgrade pip

JupyterLab sets up a web server to allow users to create multiple notebooks and scripts. If you're using a virtualenv in Python, activate the environment before installing:

$ python3 -m pip install --user jupyterlab

If you require GPU support, install the CUDA driver and TensorFlow.

Run JupyterLab

Launch JupyterLab with the --no-browser option to keep Jupyter from launching a local user interface (UI) and the --port option with a port number as input (the default port number is 8888):

$ jupyter-lab --no-browser –-port=<port_number>
Image
Execute JupyterLab
(Nicole Lama, CC BY-SA 4.0)

JupyterLab sets up a web server and outputs a URL to access the UI. Password protect your JupyterLab server by generating and modifying a Jupyter config file:

$ jupyter-lab –generate-config
$ jupyter-lab password

[ Free cheat sheet: Get a list of Linux utilities and commands for managing servers and networks. ]

After launching JuptyerLab, access the UI from a remote machine over HTTP or with SSH port forwarding. To access JupyterLab through a web browser, you must open the port to HTTP traffic using firewall-cmd:

$ sudo firewall-cmd --add-service http --permanent
$ sudo firewall-cmd –reload

Now open a browser on a remote machine and navigate to your server's IP address or hostname in the place of localhost in the URL Jupyter provides. For instance, if your server is located at 10.1.2.34, the URL of JupyterLab is 10.1.2.34:5678/lab.

If you don't want to open a firewall port for HTTP traffic, you can instead use SSH port forwarding. From a remote machine, SSH to your server, routing the JupiterLab port (5678 in this example) to some port on your local machine:

$ ssh -fL 8080:10.1.2.34:5678 user@10.1.2.34

Alternately, you can access JupyterLab directly on the local server by launching a browser and navigating to localhost:5678 (with 5678 being the port where you launched JupyterLab).

Image
Jupyter interface
(Nicole Lama, CC BY-SA 4.0)

Files and notebooks are stored in the working directory where JupyterLab is launched (that is, on the server running JupyterLab).

Try JupyterLab

A good Python IDE can simplify programming, and Jupyter Notebooks makes running your code amazingly versatile. Install JupyterLab and run your Python code as you've never run it before.

Topics:   Python   Programming   Linux  
Author’s photo

Nicole Lama

Nicole Lama is a first-generation Panamanian-American with a bachelor's in biomedical sciences and a master's in bioinformatics and computational biology. Since 2015, she has worked with academics, tech startups, and Fortune 500 companies to help meet their data extraction, transformation, mobili More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.