Jupyter Lab is a web-based interface that allows users to work with code, data, CLI, and Jupyter Notebooks all in an interactive environment entirely in the browser. This guide will provide the steps required to set up this installation on your Ubuntu server in a Python Virtual Environment and connect to the server using SSH tunneling.
1. Before you install all of the required dependencies for Jupyter, ensure your Ubuntu packages are up to date (Note: This may break your current VM if services are currently active)
sudo apt update
2. Next, install pip and the Python header files, which are used by some of Jupyter’s dependencies:
sudo apt install -y python3-pip python3-dev
- You may get a pop-up similar to the below, hit enter when this appears:
3. Now create a python virtual environment to manage your projects you create (Jupyter will be installed in this virtual environment so that you isolate any issues that could potentially occur when working on a project)
First install 'python3-venv' package:
sudo apt install -y python3-venv
4. Now that you have 'python3-venv' installed, you can start creating where your virtual environment will live. Start by creating a directory for this environment and change directories into it (You can name this directory as per your convenience):
mkdir ~/my_project
cd ~/my_project
5. Next create a virtual environment using the 'venv' python module. You can alco name it as per your convenience. This will create a folder with that name inside the folder you initially created.
python3 -m venv my_v_env
6. Before installing Jupyter, we need to activate the virtual environment. You can do that by running:
source my_v_env/bin/activate
7. This should now update your command line to the following format which will indicate you are in your virtual environment and ready to install Jupyter:
(my_v_env)user@host:~/my_project$
8. To install Jupyter, input the following command:
pip install jupyter
9. Once installed, you can run Jupyter Lab or Jupyter Notebook with:
jupyter lab
or
jupyter notebook
You will then see an output similar to the following:
[I 2025-10-30 16:48:06.141 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2025-10-30 16:48:06.143 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2025-10-30 16:48:06.146 ServerApp] jupyterlab | extension was successfully linked.
[I 2025-10-30 16:48:06.148 ServerApp] notebook | extension was successfully linked.
[I 2025-10-30 16:48:06.149 ServerApp] Writing Jupyter server cookie secret to /home/ubuntu/.local/share/jupyter/runtime/jupyter_cookie_secret
[I 2025-10-30 16:48:06.334 ServerApp] notebook_shim | extension was successfully linked.
[I 2025-10-30 16:48:06.343 ServerApp] notebook_shim | extension was successfully loaded.
[I 2025-10-30 16:48:06.345 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2025-10-30 16:48:06.345 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2025-10-30 16:48:06.347 LabApp] JupyterLab extension loaded from /home/ubuntu/my_project/my_v_env/lib/python3.12/site-packages/jupyterlab
[I 2025-10-30 16:48:06.347 LabApp] JupyterLab application directory is /home/ubuntu/my_project/my_v_env/share/jupyter/lab
[I 2025-10-30 16:48:06.347 LabApp] Extension Manager is 'pypi'.
[I 2025-10-30 16:48:06.376 ServerApp] jupyterlab | extension was successfully loaded.
[I 2025-10-30 16:48:06.378 ServerApp] notebook | extension was successfully loaded.
[I 2025-10-30 16:48:06.379 ServerApp] Serving notebooks from local directory: /home/ubuntu/my_project
[I 2025-10-30 16:48:06.379 ServerApp] Jupyter Server 2.17.0 is running at:
[I 2025-10-30 16:48:06.379 ServerApp] http://localhost:8888/tree?token=40e75af47508a3ebbe97be00f37ff36887e207bce0161745
[I 2025-10-30 16:48:06.379 ServerApp] http://127.0.0.1:8888/tree?token=40e75af47508a3ebbe97be00f37ff36887e207bce0161745
[I 2025-10-30 16:48:06.379 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 2025-10-30 16:48:06.381 ServerApp] No web browser found: Error('could not locate runnable browser').
[C 2025-10-30 16:48:06.381 ServerApp]
To access the server, open this file in a browser:
file:///home/ubuntu/.local/share/jupyter/runtime/jpserver-4315-open.html
Or copy and paste one of these URLs:
http://localhost:8888/tree?token=40e75af47508a3ebbe97be00f37ff36887e207bce0161745
http://127.0.0.1:8888/tree?token=40e75af47508a3ebbe97be00f37ff36887e207bce0161745
[I 2025-10-30 16:48:06.390 ServerApp] Skipped non-installed server(s): basedpyright, bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyrefly, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
10. If you aren’t running Jupyter on a server, you can connect to it using the link provided in the above output, for example:
http://localhost:8888/tree?token=40e75af47508a3ebbe97be00f37ff36887e207bce0161745
If you’re connecting to Jupyter using a server, you will need to connect using SSH tunneling. For that we will need to CTRL+C to stop the process and exit to reconnect again.
11. To create an SSH tunnel, it is similar to the normal SSH command except we add a few parameters:
ssh -L 8888:localhost:8888 ubuntu@<Public_Server_IP>
- ssh - opens an SSH connection
- -L - specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side (server). This means that whatever is running on the second port number (e.g. 8888) on the server will appear on the first port number on your local computer.
For assistance with configuring firewall rules to open ports if necessary, please refer to this article.
12. Once you’re back in your server, activate the virtual environment again and launch Jupyter Lab or Jupyter Notebook:
cd ~/my_project
source my_v_env/bin/activate
jupyter lab OR jupyter notebook
Copy paste the URL from the output in your local browser and Voilà!