Jupyterlab is the next generation of Jupyter Notebook with more integrated functions. Currently in the development version 0.32.1, it is already available and very powerful. According to the official website, when 1.0.0 comes out, it will replace jupyter Notebook.

This article mainly introduces the more efficient functions and configurations of JupyterLab compared with Jupyter Notebook.

Jupyterlab installation

If you have Conda, you can install it from the command line using the following command

conda install -c conda-forge jupyterlab
Copy the code

You can do this if you have a PIP

pip install jupyterlab
Copy the code

For more installation methods, see the official website

After the installation, you only need to enter the command line

jupyter lab
Copy the code

It is automatically opened with the browser.

Basic functions of JUPyterlab

The basic interface of JupyterLab is like this (the picture is from the official website)

Its editing interface is almost the same as jupyter Notebook, and the functions and shortcuts supported by Jupyter Notebook are also supported here. The advantage of JupyterLab is that it adds many components and easier operation.

Here’s a look at some of jupyterLab’s unique features

1. Open more than one window on the same document

Most of the time, when writing code, we have to refer to previous code or results, but the code and output results of the middle cell of Jupyter Notebook often make us only have to drag the scroll bar to look back, which is very troublesome. And JupyterLab provides a function of displaying documents in multiple Windows. This function alone is enough to entice me to move here from Jupyter Notebook.

Just right-click on the TAB above and select New View for Notebook to create a New TAB. Then drag the label with the mouse, as shown in the image below

Can achieve the following effect

Changes made to only one document synchronize the other immediately, and the content of the two documents can be displayed anywhere without interfering with each other. When only one document is needed, you don’t need to save it, just close the other one.

If you feel that the screenshot is not clear enough, you can check the video Create Multiple Synchronized Views of a Single Notebook section on the website

2. View the function help document quickly

Place the cursor over the function (unselected) and use the Shift + Tab shortcut to bring up more detailed help documents.

Jupyter Notebook also has this function, but the help file that comes up is very brief, so to see the help file in the Notebook, you need to run a question mark after the function.

3. Drag the cell manually

You can drag cells not only from the same file to a specified location, but also from other files. You can also drag multiple cells at a time.

4. The output is displayed in a separate window

Right-click the cell -create new View for Output, and the result will be displayed in a new window, as shown in the following figure

This is useful if you want to write code based on a previous output or graph. It’s similar to the first function, but it’s more lightweight.

5. Clear the output

Right-click the cell and select clear Output

Sometimes a program outputs so much information that it needs to be deleted when it is not needed. In the Jupyter Notebook, you can just delete the entire cell, or you can just clean up the code and run it with a blank cell and then paste the code back. By using JupyterLab, you can clear it with one button.

6. Temporary interactive test

By right-clicking on the page – New Console for Notebook, you can open an Ipython window where you can write a program and press Shift + Enter to run it.

This window can directly call all variables previously defined in the file. The code written in this window is temporary, experimental, and will not be added to the documentation. When testing is complete, just close the interface. What it does is it prevents you from testing something in a formal document and creating a bunch of useless code that you have to delete. That is, try some code without changing the source document.

More functions

More functions can refer to the official website video

Techniques by Jupyterlab

This part aims to eliminate some inconvenient places in the use of Jupyterlab

1. Cancel the sidebar

When multiple Windows are open, we do not want to display the blue area shown in the figure. At this point, the blue area corresponds to the left most files TAB (red box location), we just need to click on the Files (currently selected) TAB again, the left area is not displayed.

2. Remove the input – output

When the window is open too much, the red box in the picture will appear to take up too much space, it is best to remove it. Just go to anaconda3\share\jupyter\lab\themes\@jupyterlab\theme-light-extension \ index.css. I’m going to add at the end

.jp-InputArea-prompt {
     flex: none;
     width: 10px;
     text-indent: 100%;
 }
Copy the code

Refresh jupyterLab and you can see that the input-output is gone

3. Set the theme

At present, jupyterlab only provides white and black themes. You can view the changes through setting-Jupyterlab theme

Those who use Jupyter Notebook may know that the Jupyter-Theme project provides many excellent themes, but unfortunately it cannot be used on Jupyterlab. The team of Jupyterlab is also developing more themes, we will wait and see!

If you really want to change some Settings, you can also do so directly in the index.css file mentioned above, which can be viewed in the developer help section of the official website.

4. Add a directory for the file

You only need to enter the following command on the cli

jupyter labextension install jupyterlab-toc
Copy the code

If you open Up JupyterLab again, you can see that you have the contents option, which means that every document can be found in the directory here

Column information

Home page: Programming in Python

Table of contents: Table of contents

Version description: Software and package version description