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.
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.
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.
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.
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.
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.
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.
~/notebook-project/.venv and check python -m pip show notebook.sys.executable in both environments and choose the correct kernel.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.
For storage troubleshooting before a large notebook installation, see the Linux disk-space troubleshooting guide.
The Nandan Sinha newsletter
Get new articles on technology, practical guides, wellbeing and spirituality, delivered to your inbox.
Subscribe by email. Confirm your address to join. Unsubscribe anytime. Privacy policy.
We use essential cookies to run this website and optional cookies for analytics and advertising. Choose Accept All, Reject, or Preferences to manage optional cookies. You can change your choice at any time.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
These cookies are needed for adding comments on this website.
Google Tag Manager simplifies the management of marketing tags on your website without code changes.
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
You can find more information in our Privacy Policy and Privacy Policy.

Leave a Reply