A Guide to Installing and Using JupyterLab on Ubuntu Linux

|

|

This article details the installation and usage of JupyterLab on Ubuntu, a web-based IDE for collaborative data science work. It provides a step-by-step guide covering prerequisites, like Python 3 and pip, updating packages, creating a virtual environment, and running JupyterLab. Also included are instructions for creating notebooks, executing code, and optional uninstallation. JupyterLab on Ubuntu…

This article explains how to install and use JupyterLab on Ubuntu Linux.

JupyterLab is a web-based interactive development environment allowing easy collaboration and sharing of code and data. It is flexible and can integrate third-party extensions that enhance its functionality.

Installing and using JupyterLab on Ubuntu Linux provides a powerful data analysis, visualization, and machine learning platform. It allows users to write and execute code, document their work, and share their findings with others.

Additionally, Ubuntu Linux is a popular data science and machine learning operating system, so installing JupyterLab on it can streamline the workflow for many users.

Prerequisites

Before installing JupyterLab, ensure that you have the following prerequisites installed:

  • Python 3.x
  • pip (Python package installer)

Update System Package Index

Open your terminal and begin by updating your system’s package index:

sudo apt update
sudo apt upgrade

Install Python 3 and pip

If Python 3 is not already installed on your system, you can install it using the following command:

sudo apt install python3 python3-pip python3-venv nodejs

After installing, check the version of Python and pip:

python3 --version
pip3 --version

Install JupyterLab

With Python and pip ready, you can install JupyterLab via pip. First, create a new Python virtual environment that will be used for Jupyter installation.

With this scenario, you will have an isolated development environment that won’t affect your whole system.

Create a new directory for your project called MyLab and change into the folder using the cd command.

Then, create a new virtual environment called venv using the following command. After executing the command, the new directory venv will be created.

mkdir -p ~/MyLab
cd ~/MyLab
python3 -m venv venv
source venv/bin/activate

After creating the virtual environment above, run the command below to install JupyterLab.

pip3 install jupyterlab

Once the installation is completed, JupyterLab is ready to be used.

Run JupyterLab

To start JupyterLab, run the following command in your terminal:

jupyter-lab

This should open your default browser and launch JupyterLab. Alternatively, if it doesn’t open automatically, you can manually visit the URL it provides, usually something like http://localhost:8888/lab.

Create a New Notebook

In the JupyterLab interface,

  1. Click the “+” button to open a new tab.
  2. Under the “Notebook” section, you can create a notebook in different programming languages, depending on your installed kernels. Choose a Python 3 notebook to create a new one.

Use the Notebook

Once your notebook is open, you can start typing Python code into the cells. Press Shift + Enter to execute the code in the current cell.

Here’s an example of a simple print statement:

print("Hello, JupyterLab!")

Saving and Exiting

To save your notebook, press the save icon or go to File -> Save Notebook. To close JupyterLab, simply close the browser tabs and stop the server by pressing Ctrl + C in the terminal where it’s running.

Uninstall JupyterLab (Optional)

If you wish to remove JupyterLab from your system, you can do so using pip:

pip3 uninstall jupyterlab

Confirm the uninstallation when prompted.

Conclusion:

You have successfully installed JupyterLab on your Ubuntu system and learned the basics of starting and working with notebooks. JupyterLab is a powerful tool for data analysis, visualization, machine learning, and much more. Explore its features and consider installing extensions to enhance your JupyterLab experience further.


Discover more from Geek Rewind

Subscribe to get the latest posts to your email.

Like this:



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Discover more from Geek Rewind

Subscribe now to keep reading and get access to the full archive.

Continue reading