How to install and use Jupyter Notebook on Ubuntu

Jupyter Notebook provides an interactive workspace where you can combine Python code, explanations, equations, charts, and data in a browser window. It is useful for learning programming, analysing spreadsheets, testing Linux commands, and documenting repeatable work without building a complete software project first.

On Ubuntu, the most reliable setup uses Python’s built-in virtual environment tools. This keeps Jupyter and its libraries separate from the operating system’s own Python packages, which is especially important on recent Ubuntu releases that protect system-managed Python installations.

The instructions suit Ubuntu 22.04 LTS and Ubuntu 24.04 LTS on desktop or laptop computers. The commands work on an Ubuntu installation with a standard user account and internet access, including connections through Australia’s NBN or a university network.

Jupyter runs locally, so your notebook files remain on your computer unless you deliberately connect to a remote service or place them in cloud storage. That makes it convenient for work in Sydney, Melbourne, Brisbane, or regional areas, while still requiring sensible care with personal and business information.

Choose a clean installation method

Ubuntu includes Python 3, but its system Python is used by important operating-system tools. Installing application libraries globally with sudo pip can create conflicts with packages managed by APT. A virtual environment avoids that problem by creating a private Python installation for your notebooks.

The standard approach is to install Python’s virtual environment package, create a project directory, and activate the environment before adding Jupyter. This method is preferable to copying random installation commands from old tutorials, many of which were written before Ubuntu adopted stronger protections around system Python packages.

Open Terminal with Ctrl + Alt + T, then refresh Ubuntu’s package information:

sudo apt update
sudo apt install python3 python3-venv python3-pip

Enter your account password when requested. Nothing will appear on screen while you type it. Ubuntu may install updates from servers in Australia or another nearby region, and the download speed will depend on your NBN connection, Wi-Fi, and the selected Ubuntu mirror.

Prepare a Python workspace

Create a directory for notebooks in your home folder and move into it:

mkdir -p ~/jupyter-work
cd ~/jupyter-work

Create a virtual environment named .venv:

python3 -m venv .venv

Activate it with:

source .venv/bin/activate

When activation succeeds, the terminal prompt usually begins with (.venv). This prefix is a reminder that Python commands now use the isolated environment. If you close Terminal, you will need to run the cd and source commands again before working on the project.

Upgrade the environment’s packaging tools:

python -m pip install --upgrade pip

Using python -m pip is helpful because it ensures that pip belongs to the active virtual environment. It also avoids accidentally installing a package into a different Python version. Ubuntu computers can contain several Python executables, particularly after software development tools or university course packages have been added.

You can check which interpreter is active:

which python
python --version

The first command should display a path containing jupyter-work/.venv/bin/python. The second should show a supported Python 3 version. If the path points to /usr/bin/python3 after activation, activate the environment again from inside ~/jupyter-work.

Install Jupyter Notebook on Ubuntu

With the virtual environment active, install the classic Notebook interface:

python -m pip install notebook

This downloads Jupyter Notebook and its dependencies from the Python Package Index. The installation can take a few minutes on a slower connection. When it finishes, verify the command is available:

jupyter --version

The output lists Jupyter components and their versions. You do not need every component to have the same version number. A working installation will usually show a Notebook or Server package among the listed entries.

JupyterLab is a newer interface with tabs, file management, terminals, and a more flexible layout. It can be installed alongside classic Notebook:

python -m pip install jupyterlab

Use jupyter notebook if you want the traditional document-focused interface, or jupyter lab for the broader development environment. Both use the same virtual environment and can open the same .ipynb notebook files.

A separate option is Anaconda or Miniconda, which can simplify scientific packages such as NumPy, pandas, and SciPy. Those distributions use more disk space and a different package-management workflow. For a straightforward Ubuntu setup, a Python virtual environment is usually easier to understand and maintain.

Start the notebook server

From ~/jupyter-work, with .venv active, start Notebook:

jupyter notebook

Jupyter launches a local server and normally opens your default web browser automatically. If it does not, the terminal displays a URL similar to:

http://localhost:8888/tree?token=...

Copy that complete address into Firefox or another browser. The token is a temporary access key, so do not post it publicly or paste it into a shared chat. The localhost address means the server is running on your own Ubuntu computer rather than on a public website.

The browser file page shows the contents of ~/jupyter-work. Select New, then choose Python 3 to create a notebook. Give it a useful name, such as sales_analysis.ipynb or python-practice.ipynb. The .ipynb extension identifies a Jupyter Notebook document stored in JSON format.

A notebook is made of cells. Code cells run Python, while Markdown cells contain formatted notes and explanations. Choose a cell, select its type from the toolbar, and run it with Shift + Enter:

message = "Hello from Ubuntu"
print(message)

The result appears beneath the cell. Jupyter keeps an execution number beside code cells, helping you see the order in which they ran. That order matters because a later cell may depend on a variable created earlier.

Stop the server by returning to the terminal and pressing Ctrl + C. Confirm the shutdown if Ubuntu asks. Closing the browser tab alone does not always stop the server process.

Use Python libraries and notebook cells

For practical data work, install common libraries inside the active environment:

python -m pip install numpy pandas matplotlib

You can then load a small dataset, calculate values, and create a chart:

import pandas as pd
import matplotlib.pyplot as plt

data = pd.DataFrame({
    "city": ["Sydney", "Melbourne", "Perth"],
    "temperature": [24, 19, 28]
})

data.plot(x="city", y="temperature", kind="bar", legend=False)
plt.ylabel("Temperature")
plt.show()

This example uses Australian city names, but the same workflow can examine household expenses, survey results, school data, or a CSV exported from accounting software. If you work with customer information, health records, or employee details, keep the notebook and source files protected. The Australian Privacy Act 1988 and organisational privacy policies may apply to the data even when analysis happens locally.

Markdown cells make a notebook easier to revisit. Select Markdown from the cell-type menu and add a heading, a description of the data, or a note explaining why a calculation was performed. You can write basic formatting such as **bold text**, bullet points, and links. Press Shift + Enter to render the Markdown.

Use Kernel and Restart Kernel when Python becomes stuck or variables produce confusing results. Restarting clears variables from memory, so run the cells from the beginning afterwards. The Run All command is useful when checking that a notebook works from a clean session rather than relying on cells accidentally run in an earlier order.

To save a copy, use File > Save and Checkpoint or press Ctrl + S. A notebook saves the code, outputs, and Markdown together. Large images and extensive output can make files unwieldy, so clear unnecessary output before sharing a notebook by using the relevant Cell or Kernel menu command.

Add files, kernels, and useful tools

Jupyter’s file browser starts in the directory where the server was launched. Keep related CSV files, images, and notebooks in organised folders:

mkdir -p data figures

A notebook can refer to a file in the data directory with:

import pandas as pd

records = pd.read_csv("data/example.csv")
records.head()

Relative paths make a project easier to move between a home computer and another Ubuntu machine. They also avoid hard-coding a path such as /home/alex/Downloads, which will fail for another user.

If you install another Python environment later, Jupyter may need a separate kernel so it can use that environment. In the active virtual environment, install the kernel package and register it:

python -m pip install ipykernel
python -m ipykernel install --user --name ubuntu-jupyter --display-name "Python (Ubuntu Jupyter)"

In a notebook, choose Kernel > Change Kernel and select Python (Ubuntu Jupyter). This is useful when a project needs a particular Python version or specialist packages. If a library imports successfully in Terminal but fails in the notebook, the notebook may be using a different kernel.

For interactive charts, additional packages may be required. Install them in the same environment that owns the selected kernel. A simple rule is to activate .venv, install the package there, and restart the kernel before testing the import again.

Keep the local server secure and maintained

By default, Jupyter listens on the local computer, which is a sensible setting for personal use. Avoid launching it with options such as --ip=0.0.0.0 unless you understand firewall rules, authentication, and the risks of exposing notebooks to a network. Anyone who can access an unsecured Jupyter server may be able to run commands with your user permissions.

This matters on shared home networks, office Wi-Fi, and university accommodation. A notebook server should never be treated as a public web service simply because it opens in a browser. Keep Ubuntu updated, use a strong account password, and close the server when you finish.

Update the packages in the virtual environment periodically:

cd ~/jupyter-work
source .venv/bin/activate
python -m pip install --upgrade notebook jupyterlab

If a command is missing, check that .venv is active. If the browser reports that port 8888 is busy, start Jupyter on another local port:

jupyter notebook --port=8889

If the page does not open, copy the URL shown in Terminal and check that the server is still running. For permission errors, place the project inside your home directory rather than a system folder. For package import errors, confirm the selected kernel and install the missing library into that kernel’s environment.

Jupyter Notebook works best when treated as a small, self-contained Python project. Create a virtual environment, install packages inside it, launch the server from the project folder, and keep sensitive data out of files that may be shared. The key idea to remember is that the browser is only the interface: the Jupyter server, Python environment, notebooks, and data all live on your Ubuntu computer.