5 Extensions That Will Make You Switch to Jupyter Lab | by Frank Andrade | Towards Data Science

Jupyter Lab is known as Jupyter’s next-generation notebook interface. It integrates the notebook, console, text editor, and terminal into a single interactive and collaborative environment.
Apart from bringing the classical notebooks and text editor, Jupyter Lab also offers third-party extensions. As we’ve seen in a previous article, Jupyter Notebook only provides a limited number of native extensions; however, Jupyter Lab contains a robust and thriving third-party extension community. In this guide, I’ll show you 5 extensions that will make you think about switching to Jupyter Lab.
In case you’ve been using only Jupyter Notebooks and never heard of Jupyter Lab, below there’s a quick setup (jump to the extension section, in case you’re familiar with Jupyter Lab)
Table of Contents1. Installing JupyterLab2. How to Install Extensions3. Extensions Available by Default on JupyterLab 3.0+4. Extension 1: JupyterLab Spreadsheet5. Extension 2: Interactive Graphs with Plotly and Chart Editor6. Extension 3: Drawing with JupyterLab-DrawIO7. Extension 4: Auto-completion to A Next Level with Kite8. Extension 5: Debugger
As mentioned in its documentation, you can easily install Jupyter Lab with conda or pip.
# condaconda install -c conda-forge jupyterlab# pippip install jupyterlab
After the installation, run the following command to open Jupyter Lab
jupyter lab
There are two types of JupyterLab extensions: source extensions and prebuilt extensions. Source extensions require Node.js to be installed. According to the documentation, you can install Node.js with the following command.
# condaconda install -c conda-forge nodejs# pippip install nodejs
However, I still got the message “You need to install Node.js” when trying to install extensions. I solve this issue by downloading the “recommended for most users” Node.js from its website and installing it directly.
Once you have Node.js, everything is set to install extensions. There are 2 ways to install extensions in Jupyter Lab.
You can easily install extensions with the extensions manager. Just follow these steps.
Click the extensions manager icon located on the left sidebar.Click on the “Enable” button.Search any library you want and then install it.
Click the extensions manager icon located on the left sidebar.
Click on the “Enable” button.
Search any library you want and then install it.
To install extensions, run the following code in the command prompt or terminal
jupyter labextension install name-of-extension
Instead of writingname-of-extension, you can also write the local directory containing the extension, a gzipped tarball, or a URL to a gzipped tarball. In case you want to specify a specific version, write name-of-extension@version, for example.
jupyter labextension install name-of-extension@1.2.3
Note: After installing any extension, a message “A build is needed to include the latest changes” will show up below the search box. Make sure you click the “rebuild” button every time you install a new extension, then wait till a new message pop up and click “save and reload”
Now it’s time to see the extension that I believe might tempt you to switch to Jupyter Lab!
For JupyterLab 3.0 or above, there are some extensions available by default like a table of content. Also, as you can see in the gif below, it’s possible to drag each tab side-by-side, resize them, copy cells between notebooks, drag and drop cells, hide code, and change themes without installing any extension!
By default, you can open multiple .csv files on Jupyter Lab; however, if you try to open a .xlsx file you’ll get an error. This is when you need to install a third-party extension called jupyterlab-spreadsheet
To install it, just write jupyterlab-spreadsheet on the search box or run the command jupyter labextension install jupyterlab-spreadsheet. A spreadsheet in Jupyter Lab looks like this.
Plotly is a graphing library that makes interactive graphs. It’s also available in Jupyter Notebook, but with the jupyterlab-chart-editor you can even edit Plotly charts through a user-friendly point-and-click interface.
First, make sure you have the Plotly library installed (pip install plotly) and also JupyterLab has theipywidgets packages installed.
#conda conda install jupyterlab "ipywidgets>=7.5"# pippip install jupyterlab "ipywidgets>=7.5"
Then open up a terminal and run jupyter labextension install jupyterlab-plotly to install the Plotly extension. After this, you should be able to plot interactive graphs like the one below (use the code here to try your first plot)
Now you can easily edit these Plotly graphs with JupyterLab-chart-editor. Open up a terminal and run jupyter labextension install jupyterlab-chart-editor to install the chart editor.
To see it in action you have to save a Plotly figure you made to JSON
pio.write_json(fig, 'example.plotly')
In this example I made a file named ‘example.plotly’. To open it right-click ‘example.plotly’ from the file menu and open with "Plotly Editor". A window like this should open.
Here you can make some changes and then use the file menu to save the file again and import it back to your original notebook.
fig_styled = pio.read_json('example.plotly')
Draw.io is a free online diagram software for making flowcharts, process diagrams, etc. With thejupyterlab-drawiothird-party app, you can have all the functionalities inside Jupyter Lab.
To install it, just search jupyterlab-drawioor run the command jupyter labextension install jupyterlab-drawio. Then a new “Diagram” icon should show up in the Launcher tab.
Click on it to open a new .dio file. Now you can draw anything you want!
Kite takes auto-completion to a next level with fast completions that are context-aware of your code. Although Jupyter Notebook offers auto-completion, it contains some bugs that make writing code not as fluent as in your favorite text editor or IDE.
Fortunately, with Kite you will get longer multi-line completions where you would typically get none. On top of that, you can view Python docs with just mouse-hover, plus find helpful examples and how-tos.
To install it, make sure you have the following requirements:
JupyterLab >=2.2.0
Kite Engine
Python 3.6+ with pip
To install the Kite Engine, go to their Github page and scroll down until the Installation section. Download the installer for your OS and install it like any program. If the installation was successful, you should see Kite among the installed extensions. Now write some code to see Kite’s autocompletion in action.
To check all the text editors/IDE compatible open Kite, then go to settings, and click on plugins.
A useful feature that most IDE support and Jupyter lacks is the debugger. It comes by default with Jupyter 3.0 +; however, if you don’t have it on Jupyter Lab, follow the steps below to install it.
First, search jupyterlab/debuggeror run the command jupyter labextension install jupyterlab/debugger to install the debugger. Then, in the back-end, a kernel implementing the Jupyter Debug Protocol is required. For now, the only kernel implementing this protocol is xeus-python a new Jupyter kernel for the Python programming language. To install xeus-python, run the following command on the terminal.
# condaconda install xeus-python -c conda-forge#pippip install xeus-python
Just keep in mind that the pip option is still experimental. Once xeus-python and the debugger extension are installed, open a new xpython and click the bug icon on the right to expand the debugger.
That’s it! Other cool extensions like Google Drive, Github, and language packs are also available. Make your life easier with a new extension!
Join my email list with 3k+ people to get my Python for Data Science Cheat Sheet I use in all my tutorials (Free PDF)