Install Jupyter Notebook on Ubuntu 22.04: A Safe Setup
To install Jupyter Notebook on Ubuntu 22.04, use a Python virtual environment and run the server as an ordinary user. This keeps project packages separate from Ubuntu’s system Python and gives you a straightforward way to start, verify and stop a single-user notebook session.
The walkthrough supports a local Ubuntu machine or a remote server reached through SSH. It does not expose the notebook port publicly. Commands should be run in your own authorised environment; package compatibility depends on the Python and Notebook versions you install.
Table of Contents
Install Jupyter Notebook on Ubuntu 22.04: Before installing Jupyter Notebook on Ubuntu 22.04
You need an ordinary user account, sudo permission for system packages, network access to the configured Ubuntu and Python package repositories, and a browser on your own computer. For a remote machine, confirm that SSH access works first.
Use a new project directory if you already have an environment with this name. Avoid changing the system Python interpreter or installing project packages with sudo pip.
1. Install Python prerequisites
sudo apt update
sudo apt install python3 python3-venv python3-pip
python3 --version
These commands refresh package metadata and install the Python tools used below. They do not perform a full operating-system upgrade. Plan broader updates and any required restart through your usual maintenance process.
2. Create a dedicated virtual environment
mkdir -p ~/notebook-project
cd ~/notebook-project
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install notebook
jupyter notebook --version
Activating the environment makes its Python and installed command-line tools available in the current shell. Use python -m pip so package installation follows the interpreter you selected. The Notebook interface can differ between releases; the current notebook package should not be confused with screenshots of older classic releases.
If installation reports an unsupported Python version, read the package’s requirements and choose a supported combination. Do not force an incompatible installation or replace Ubuntu’s system interpreter to make it work.
Before you install Jupyter Notebook on Ubuntu 22.04, identify the user account, project directory and intended access path.
3. Start Jupyter on localhost
jupyter notebook --no-browser --ip=127.0.0.1 --port=8888
Leave this terminal open. Jupyter prints connection information and normally provides a token-protected URL. Keep that token private: notebook access allows code execution with the permissions of the account running the server.
On a local Ubuntu desktop, open the printed localhost URL in your browser. Keep authentication enabled. If the requested port is occupied, check the actual port reported by the server rather than assuming it started on 8888.
4. Connect to a remote notebook through SSH
From your own computer, run the following command in another terminal. Replace the account and hostname with your authorised SSH destination.
ssh -N -L 8888:127.0.0.1:8888 youruser@your-server
Open http://127.0.0.1:8888 locally and authenticate with the token from the remote Jupyter session. The tunnel forwards the local port to the remote machine’s loopback interface; an inbound public rule for port 8888 is unnecessary for this design.
If the local port is already used, try ssh -N -L 8889:127.0.0.1:8888 youruser@your-server and open local port 8889. If Jupyter selected a different remote port, change the final port in the tunnel accordingly.
If you install Jupyter Notebook on Ubuntu 22.04 on a remote host, keep the server’s authentication enabled when using an SSH tunnel.
5. Verify the notebook and Python kernel
Create a Python notebook through the interface. Run these simple cells, save the notebook and reopen it:
import sys
print(sys.executable)
print(2 + 2)
Check that the interpreter belongs to the intended virtual environment and that the calculation returns 4. A successful browser login alone does not confirm that the selected kernel uses the environment you expected.
If you need a named kernel for this environment, activate it and register one deliberately:
python -m pip install ipykernel
python -m ipykernel install --user --name notebook-project --display-name "Python (notebook-project)"
Select that kernel in the notebook interface. Kernel registration records a path to the interpreter; moving or deleting the environment can leave a stale entry.
Common installation problems
- venv creation fails: confirm that the matching Ubuntu venv package is installed and inspect the complete error.
- jupyter is not found: reactivate
~/notebook-project/.venvand checkpython -m pip show notebook. - The browser cannot connect: verify the server is running, check its chosen port and confirm the SSH tunnel has not closed.
- A package imports in the terminal but not the notebook: compare
sys.executablein both environments and choose the correct kernel.
Stop cleanly and keep the project reproducible
Stop the server with Ctrl+C in its terminal and confirm shutdown when prompted. Close the SSH tunnel separately, then run deactivate in the environment shell. Save notebook files in a backed-up project location.
For a project you need to reproduce, record dependency versions with python -m pip freeze > requirements.txt. Review updates before applying them to an established environment. A multi-user service needs a separate design for identity, HTTPS, isolation and operations; consider JupyterHub rather than sharing one user’s token.
Use a virtual environment
Install Jupyter inside a Python virtual environment so its packages stay separate from system Python. This avoids version conflicts and makes cleanup easy.
Running Jupyter securely
By default it listens on the local machine. If you need remote access, prefer an SSH tunnel over opening the port to the internet. When exposing it, enable authentication, use HTTPS and restrict access by firewall.
Running it as a service
For a persistent setup, create a systemd service that starts Jupyter as a normal user, with a defined working directory, and check its logs if it fails.
Troubleshooting
If the command is not found, activate the environment. If the browser cannot connect, check the port, bind address and firewall. Kernel problems often come from missing packages in the environment.
Before you install Jupyter Notebook on Ubuntu 22.04 for a team, decide where notebooks will live and who may reach the server. To install Jupyter Notebook on Ubuntu 22.04 safely, use a virtual environment and keep the service bound to the local machine. Whenever you install Jupyter Notebook on Ubuntu 22.04 on a new server, repeat the same documented steps and test with a simple notebook. A short checklist makes it easy to install Jupyter Notebook on Ubuntu 22.04 consistently.
If you are new to this, follow a guide to install Jupyter Notebook on Ubuntu 22.04 once, keep your notes, and reuse them whenever you need to install Jupyter Notebook on Ubuntu 22.04 again or help a colleague install Jupyter Notebook on Ubuntu 22.04.
Frequently asked questions
Notebook or JupyterLab? JupyterLab offers a richer interface; both run similar notebooks.
Can multiple users share it? Consider JupyterHub for that.
How do I back up notebooks? Keep them in version control.
Key takeaways
- Use virtual environments.
- Tunnel over SSH rather than exposing ports.
- Run as a non-root service user.
Install Jupyter Notebook on Ubuntu 22.04: official references
- Project Jupyter installation
- Python virtual environments and pip
- Jupyter Server deployment guidance
- IPython kernel registration
For storage troubleshooting before a large notebook installation, see the Linux disk-space troubleshooting guide.
Related reading: Scikit-Learn Tutorial: Build and Evaluate Your First Model · Ubuntu System Restart Required: 5 Safe Reboot Checks





Leave a Reply