JupyterLab can be viewed as the evolution of the Jupyter Notebooks, an open-source web application that allows combining interactive code (Python, R, Matlab, C++, etc.), equations, text and rich outputs. JupyterLab provides full support for Jupyter Notebooks and add powerful capabilities, such as text editors, terminals, data file viewers, interactive plotting, etc. In this session we will provide a brief overview of the main capabilities of JupyterLab and Jupyter Notebooks with a focus on Data Science applications.
What is JupyterLab?
JupyterLab is a very powerful tool for research and teaching. It extends the functionalities of Jupyter Notebooks in a web-based application that allows combining notebooks with text editors, terminals, data and figure viewers, extensions, etc., while being compatible with different programming languages (Kernels).
In particular, we can highlight the following characteristics:
- Code Consoles, that can be linked to a notebook kernel for interactive computing.
- Interactive control of notebook cell contents and outputs.
- Real-time editing of documents (Markdown, CSV, etc.)
- Compatible with several file and data formats (CSV, JSON, Geojson, PDF, Vega, etc.)
- Large variety of extensions for customization.
- Open-source.
Two examples of relevant applications where these tools are used are:
In the following, most of the images and outputs displayed in the post have been obtained from the demo notebooks available here (JupyterLab official documentation).
Installing JupyterLab
There are several options to install JupyterLab, some of these are:
- By using
conda
:
conda install -c conda-forge jupyterlab
- By using
pip
:
pip install jupyterlab
JupyterLab is also included as a default module in the standard Anaconda Distribution.
Installing Kernels
As indicated, it is possible to work with several programing languages (kernels
) in JupyterLab. The default Anaconda Distribution already includes the IPython kernel to work with Python. Other relevant kernels can be installed by following these links:
Starting JupyterLab
Once installed, JupyterLab can be started by simply typing this in the Windows or Mac console:
jupyter lab
Then JupyterLab will open in your default internet browser (Chrome, Safari, Firefox, etc.)
The interface
The main interface includes a main work area, which contains tabs of notebooks, consoles and activities, a left sidebar and a menu bar.
Menu Bar
Includes top-level menus with several options available in JupyterLab. The default ones are: File
, Edit
, View
, Kernel
, Tabs
, Settings
and Help
.
Left Sidebar
Contains several tabs that allow file browsing, check the running kernels, show the command palette and verify the open tabs. Moreover, the panel can be expanded with optional extensions.
Main Work Area
In this area, documents (notebooks, images, consoles, datasets) are organized in panels or tabs that can be subdivided or resized to ease the workflow.
Working with Files
Create a new file
If we click on the +
icon in the tab menu we will open a new Launcher tab in the main work area where we can select the type of file we want to create. These will depend on the number of available kernels installed in our system as well as other extensions that we have incorporated to JupyterLab. The new files main include Jupyter Notebooks, consoles, terminals, diagrams, Latex files, etc.
Opening or closing files
The File
tab includes several options to create, save and export files depending on their nature.
Text Editor
JupyterLab includes a highly configurable text editor that includes syntax highlighting and automatic indentation, compatible with several programming languages.
Jupyter Notebooks
One of the main capabilities of JupyterLab is that it offers full support to work with Jupyter Notebooks (.ipynb
files). In this type of files we can combine runnable code (R, Python, Matlab, C++, etc.) with text (Markdown), LaTeX equations, images and interactive graphs.
In this session, we will explore some of the main capabilities of Jupyter Notebooks and their potential use in research and teaching. On top of this, JupyterLab enables new functionalities to the notebooks that include:
- Drop and drag cells within the notebook.
- Drag cells between notebooks.
- Expand and collapse cells.
- Create multiple views (synchronized) of a notebook.
- Connect a code console to a notebook kernel.
- Tab autocompletion in the editor.
- Change themes.
Code Consoles
This functionality allows running code interactively in a kernel. The cells also include rich output such as Tab-completion.
Extensions
JupyterLab is highly customizable through extensions, that can provide new file viewers, editors, themes, etc. The first step to install new extensions is to install Node.js
:
conda install -c conda-forge nodejs
Then the new extensions can be installed with the following syntax:
jupyter labextension install my-extension
where my-extension
stands for the name of the specific extension. The list of already installed extensions in your system can be checked by:
jupyter labextension list
Among many options, some interesting extensions are:
Interactive widgets
jupyter labextension install @jupyter-widgets/jupyterlab-manager
Allows using the interact
function to explore code, data and graphs interactively.
GeoJSON
jupyter labextension install @jupyterlab/geojson-extension
Allows rendering GeoJOSON outputs in the notebook.
Drawio
jupyter labextension install jupyterlab-drawio
Integration of software to create and export diagrams.
Latex Editor
jupyter labextension install @jupyterlab/latex
Allows real-time editing of LaTeX documents.
Google Drive
jupyter labextension install @jupyterlab/google-drive
Adds Google Drive folder browser to the left panel.
GitHub
jupyter labextension install @jupyterlab/github
Allows accessing GitHub repositories.
Final Thoughts
In this session we have explored some of the main JupyterLab capabilities. We have seen how it combines a rich web-based interface with a great variety of editing, coding and graphical tools that can be very interesting for the data science community, including practitioners, researchers and students.