- IPython Interactive Computing and Visualization Cookbook(Second Edition)
- Cyrille Rossant
- 758字
- 2021-07-02 16:23:35
Introducing JupyterLab
JupyterLab is the next generation of the Jupyter Notebook. It aims at fixing many Notebook usability issues and it greatly expands its scope. JupyterLab offers a general framework for interactive computing and data science in the browser, using Python, Julia, R, or one of many other languages.
In addition to providing an improved interface to existing notebooks, JupyterLab also brings, within the same interface, a file browser, consoles, terminals, text editors, Markdown editors, CSV editors, JSON editors, interactive maps, widgets, and so on. The architecture is completely extensible and open to developers. In a word, JupyterLab is a web-based, hackable IDE for data science and interactive computing.
JupyterLab uses the exact same Notebook server and file format as the classic Jupyter Notebook, so that it is fully compatible with existing notebooks and kernels. Notebook and JupyterLab can run side to side on the same computer. You can easily switch between the two interfaces.
Getting ready
To install JupyterLab, type conda install -c conda-forge jupyterlab
in a Terminal.
To be able to render GeoJSON files in an interactive map, install the GeoJSON JupyterLab extension with: jupyter labextension install @jupyterlab/geojson-extension
.
How to do it...
- We can launch JupyterLab by typing
jupyter lab
in a Terminal. Then we go tohttp://localhost:8888/lab
in the web browser. - The dashboard shows, on the left, a list of files and subdirectories in the current working directory. On the right, the launcher lets us create notebooks and text files, or open a Jupyter console or a Terminal. Available Jupyter kernels are automatically displayed (here, IPython, but also IR and IJulia).
- On the left panel, we can also see a list of open tabs, a list of running sessions, or a list of available commands:
- If we open a Jupyter notebook, we get an interface that closely resembles the classic Notebook interface:
There are a few improvements compared to the classic Notebook. For example, we can drag and drop one or several cells:
We can also collapse cells.
- If we right-click in the notebook, a contextual menu appears:
If we click on Create Console for Notebook, a new tab appears with a standard IPython console. We can drag and drop the tab anywhere in the screen, for example below the notebook panel:
The IPython console is connected to the same kernel as the Notebook, so they share the same namespace. We can also open a new IPython console from the launcher, running in a separate kernel.
- We can also open a system shell directly in the browser, using the term.js library:
- JupyterLab includes a text editor. We can create a new text file from the launcher, rename it by giving it the
.md
extension, and edit it:Let's right-click on the Markdown file. A contextual menu appears:
We can add a new panel that renders the Markdown file in real time:
We can also attach an IPython console to our Markdown file. By clicking within a code block and pressing Shift + Enter, we send the code directly to the console:
- We can also create and open CSV files in JupyterLab:
The CSV viewer is highly efficient. It can smoothly display huge tables with millions or even billions of values:
- GeoJSON files (files that contain geographic information) can also be edited or viewed with the Leaflet mapping library:
There's more...
JupyterLab is fully extendable. In fact, its philosophy is that all existing features are implemented as plugins.
It is possible to work collaboratively on a notebook, as with Google Docs. This feature is still in active development at the time of writing.
Here are a few references:
- JupyterLab GitHub project at https://github.com/jupyterlab/jupyterlab
- Jupyter renderers at https://github.com/jupyterlab/jupyter-renderers
- Talk at PyData 2017, available at https://channel9.msdn.com/Events/PyData/Seattle2017/BRK11
- Talk at PLOTCON 2017, available at https://www.youtube.com/watch?v=p7Hr54VhOp0
- Talk at ESIP Tech, available at https://www.youtube.com/watch?v=K1AsGeak51A
- JupyterLab screencast at https://www.youtube.com/watch?v=sf8PuLcijuA
- Realtime collaboration and cloud storage for JupyterLab through Google Drive, at https://github.com/jupyterlab/jupyterlab-google-drive
See also
- The Introducing IPython and the Jupyter Notebook recipe in Chapter 1, A Tour of Interactive Computing with Jupyter and IPython