How to Install Jupyter Notebook in Debian or Ubuntu Linux

3 min


A simple tutorial on how to install Jupyter Notebook in Ubuntu or Debian Linux.

Jupyter Notebook is a powerful web-based interactive dev tool which allows you to create and share live code, visualizations, and interactive data. Its notebook format combines code and text, making it an excellent choice for data exploration, analysis, and collaborative projects.

In this tutorial, we will guide you through the step-by-step process of installing Jupyter Notebook on Ubuntu or Debian -based systems, enabling you to harness its versatility and extend your programming capabilities.

Install pip

Before we begin, ensure that pip, the Python package installer, is installed on your system. If you already have pip installed, you can skip this step. Otherwise, follow these instructions to install it. You can also visit this page for detailed instructions.

Open a terminal window (Ctrl+Alt+T) and type the following command; press Enter:

sudo apt update
sudo apt install python3-pip

You may be prompted to enter your password. Provide it and wait for the installation to complete.

Install virtualenv

Although not mandatory, it is recommended to isolate your work environment via this tool in the Jupyter Notebook installation. This ensures that any changes or packages you install will not interfere with your system’s Python environment. To set up a virtual env, follow the below steps:

In the terminal, enter the following command:

sudo apt install python3-virtualenv

Wait for the installation to finish. Once complete, proceed to the next step.

Create a virtual environment

Creating a virtual environment is a straightforward process. Here’s how you can set up a new virtual environment specifically for Jupyter Notebook:

Navigate to the directory where you want to create the virtual environment. Run the following command in the terminal:

virtualenv my-jupyter-env

This command creates a new directory called “my-jupyter-env”, which will contain the virtual environment files.

create jupyter environment
create jupyter environment

You can also verify that the directory is created under your home folder via any file manager.

jupyter env folders
jupyter env folders

Activate the virtual environment by entering the following:

source my-jupyter-env/bin/activate

You will notice that your terminal prompt changes to indicate that you are now inside the virtual environment.

activate the environment
activate the environment

Install Jupyter Notebook

With the virtual environment activated, you can now proceed to install Jupyter Notebook:

In the terminal, type the following command:

pip install jupyter

This command fetches the necessary packages and installs Jupyter Notebook in your virtual environment.

Installing jupyter using pip
Installing jupyter using pip

Launch Jupyter Notebook

Once the installation is complete, you are ready to launch Jupyter Notebook:

In the terminal, type the following command:

jupyter notebook

After executing the command, Jupyter Notebook will start, and you should see an output similar to this:

running jupyter notebook in Debian
running jupyter notebook in Debian

Your default web browser will open, displaying the Jupyter Notebook interface.

Jupyter notebook running in browser
Jupyter notebook running in browser

Shutting down and restart

If you want to shutdown the Notebook server, make sure to close and save all notebooks. Close the browser. Then press “CTRL+C” in the terminal window. It will prompt you whether you want to shutdown the server. Type Yes and hit enter. And finally, close the terminal window.

To restart the server again, you need run all the commands from “virtualenv my-jupyter-env” as described above.

Conclusion

Congratulations! You have successfully installed Jupyter Notebook on your Ubuntu or Debian system. By following the above steps, you can now take advantage of Jupyter’s interactive development environment to write code, create visualizations, and explore data effortlessly.

Remember, Jupyter Notebook supports various programming languages, including Python and offers a vast list of plugins to extend its functionality further.


Arindam

Creator and author of debugpoint.com. Connect with me via Telegram, 𝕏 (Twitter), or send us an email.
Subscribe
Notify of
guest

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

2 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments