Demo
In this demo, you’ll be guided through installing JupyterLab on MacOS. The process will be quite like that on other operating systems due to the chosen installation method.
For macOS users, you can go to your terminal and install JupyterLab with Homebrew using the following command: brew install jupyterlab
. If you don’t have Homebrew, you can keep watching to see and use the installation procedure for the other platform users.
Setting up Python With Conda
You’ll need to set up Python on your system if you don’t have it already. To fix this, you’ll use Conda. Conda is a package management tool for multiple platforms. It’s especially helpful for managing data science programming tools across different platforms.
- Visit conda.io/projects/conda/en/latest/index.html
- Follow the instructions for your specific operating system. Conda provides installers for all major operating systems, making the process straightforward.
- Download and run the executable.
- Complete the installation process, which might take a few minutes.
-
Open a terminal session and type the following command to verify that Conda is installed correctly:
conda --version
If successful, it will display the installed Conda version. -
Next, check whether Python is installed by running
python --version
in the terminal. This should show the available Python version.
Installing JupyterLab
Visit the Project Jupyter website at jupyter.org. JupyterLab is a product of the Jupyter Project. It’s an interactive web application designed for computing data science and scientific data. There are other tools from the Jupyter Project, but you’ll use JupyterLab for this module.
- Click “Install” from the header navigation bar to visit the installation page.
- Here, you see instructions for installing JupyterLab. JupyterLab is provided as a Python package. This means you can install it on your operating system, just like any other Python package.
-
In your terminal, execute the following command to install JupyterLab:
pip install jupyterlab
. -
Once the installation is complete, launch JupyterLab by typing:
jupyter lab
.
This opens a tab in your default browser.
Exploring the JupyterLab Interface
Take a moment to familiarize yourself with the interface.
At the top are menu tabs. On the left sidebar is a File Browser. When opened, it shows a panel to the right displaying open editors in your main window and the folder structure of the current directory in your terminal from which you started JupyterLab.
Below the File Browser is the Running Terminals and Kernels button. It displays open tabs, active kernels, language servers, and terminals.
“Table of Contents” is next. This panel displays the headings in notebooks and other supported files.
Last on the side column is the “Extension Manager”. It displays installed extensions.
In the main window, you see the Launcher tab. The Launcher shows three categories of files and views you can create in your lab.
The first group is the notebook.
Notebooks
A notebook is a special kind of file that contains cells. Each cell has an input and an optional output section. You write code in the input section and see its results in the output section. A cell can take a Python code, markdown, or raw text. JupyterLab has nice syntax highlighting for each type of data you input in a cell.
You’ll be spending much of your time in a notebook, so take a look around your new home.
A notebook features a kernel. The kernel is the underlying engine that’ll compute the commands you input in the cell. The current kernel can be seen at the right top corner of the notebook tab.
At the opposite end is the Save button. The file’s usually saved automatically after a period.
To the right of the save button is the Insert cell button. This creates a cell below the last cell.
The next button is the Cut cell button, which cuts a cell, whereas the button right after it copies the cell instead.
After the copy button is the Paste button, which pastes a cell that was previously cut or copied.
The Run button is used to execute the code in a cell and advance to a new cell. You’ll usually click Shift-Return as a shortcut to this button.
While the kernel is running code in a cell, you can use the Interrupt button to stop it.
The next button is another important one: Restart. It’s used to restart the kernel, which is especially useful when it enters a bad state.
The next Restart button with the two right arrows behaves a bit differently from the one you just saw. This one restarts the kernel and runs all the commands in all the cells from the beginning of the notebook to the bottom.
The dropdown is used to change the type of cell. A cell type determines the kind of text that goes in there and how the notebook interprets it. The three types of cells are code, markdown, and raw.
Then, there’s the Preview button. It opens a preview window showing a rendered view of the notebook.
Consoles
Return to the “Launcher” tab and look at the console. A console is simply a Python terminal session. It presents a Python output view in the center and a cell at the bottom. It’s for running Python code only.
Other File Types
And finally, there is the “Other” category. This presents different kinds of files and applications you can view. These include a terminal, text file, markdown file, Python file, and a contextual help window showing documentation for any Python function you execute in the cell.
That does it for getting started with JupyterLab. Continue to the concluding section of this lesson.