Skip to content
Ubuntu Linux

How to Install JupyterLab on Ubuntu: A Step-by-Step Guide

Richard
Written by
Richard
Updated 6 min read
Enable Auto Login on Ubuntu Linux: Step-by-Step Guide
Enable Auto Login on Ubuntu Linux: Step-by-Step Guide

JupyterLab gives you a web-based, interactive coding environment on Ubuntu. It is widely used for data science and machine learning, and it works just as well for general Python scripting, teaching, and quick experiments. You run it on your own machine and use it through your browser.

⚡ Quick Answer

Install pip with sudo apt install python3-pip, create a virtual environment using python3 -m venv jupyter-env, activate it with source jupyter-env/bin/activate, then install JupyterLab by running pip install jupyterlab. Start it with jupyter lab.

Advertisement

JupyterLab is the current user interface for Project Jupyter. It replaces the older classic Notebook interface. In one browser tab you can write and run code in notebooks, edit plain text and Markdown files, open a terminal, browse your project files, and view output such as tables and charts. The panels sit side by side, so you can keep a notebook next to a data file or a terminal.

This guide covers installing JupyterLab version 4.0 or later on Ubuntu. Before you start, make sure you have the following:

  • A supported Ubuntu release. Any current LTS release, such as 22.04 or 24.04, works.
  • Python 3. Ubuntu ships with it, but check that it is installed and note which version you have. JupyterLab 4 needs a reasonably recent Python 3, so very old releases may not work. Ubuntu 22.04 and 24.04 both ship a version that is new enough.
  • pip, the Python package installer. It is not always installed by default, so you may need to add it with apt.
  • A user account with sudo rights. You need this to install system packages such as pip and the Python venv module.
  • An internet connection, because the packages are downloaded when you install.

One thing to know about newer Ubuntu releases: from 23.04 onward, including 24.04, Ubuntu marks the system Python as “externally managed” (this is defined in PEP 668). If you try to install packages into it with pip, you get an externally-managed-environment error instead of an install. This is intentional. It stops pip from overwriting packages that Ubuntu itself depends on. Ubuntu 22.04 does not do this, so on that release a plain pip install still works, though a virtual environment is still the better habit.

Advertisement

The error is not something to force past. Do not work around it by overriding the protection. Pick one of the isolated approaches below instead. Each keeps JupyterLab separate from the system Python, and you can remove it later without affecting anything else.

  • A virtual environment (venv). This is the standard choice and uses only tools that come with Python plus Ubuntu’s venv package.
  • pipx. It installs a Python application into its own private environment and puts its launcher on your path. It suits you if you only want JupyterLab as a tool and do not plan to add many libraries to it.
  • uv. A fast Python package and environment manager. It can create environments and install JupyterLab into them, and it can also run JupyterLab as a standalone tool.
  • conda or mamba from conda-forge. These are a good fit if you manage data science packages, such as NumPy, pandas or compiled libraries, and want each project in its own environment. Install a conda distribution such as Miniforge, which uses conda-forge by default, then create an environment and install JupyterLab from the conda-forge channel. mamba does the same job with a faster dependency solver.

To install with the venv method, follow these steps:

  1. Install the Python venv module and pip with apt, using sudo. You should see apt finish without errors. If a package is already installed, apt tells you so.
  2. Choose a folder for the environment, for example a hidden folder in your home directory, and create a new virtual environment there with Python 3.
  3. Activate the environment. Your shell prompt should now start with the environment name in brackets. That tells you the environment is active.
  4. Install the jupyterlab package with pip. This time pip works, because it is writing into your environment and not the system Python. Wait for it to report a successful install.

Whichever method you use, install and start JupyterLab from the same environment. If you open a new terminal later and the command is not found, the environment is probably not active. Activate it again, or use the full path to the launcher inside the environment. To remove a venv install, deactivate the environment and delete its folder. For pipx, uv or conda, use that tool’s own uninstall or remove-environment option.

Once JupyterLab is installed and started, it runs a local server, by default on port 8888, and opens in your default browser. To start it, run the JupyterLab launcher from your terminal with the environment active. The terminal then stays busy and prints log lines, including the address of the server. Leave that terminal open while you work. To stop the server, press Ctrl+C in that terminal and confirm when asked. If port 8888 is already in use, JupyterLab picks the next free port, such as 8889, so always read the address it prints.

The server protects itself with a token. On startup it prints a URL that ends with a long random token. Opening that full URL logs you in. If your browser opens on its own, it already uses this URL. If you open the page without the token, you see a login screen. There you can paste the token, or paste it together with a new password to set one. After that you can log in with the password and no longer need the token. The token changes each time the server starts, unless you have set a password.

If you are working on a remote server or a machine with no desktop, there is no browser to open on that machine. Start the server without launching a browser, then reach it from your own computer. The safe way to do this is SSH port forwarding, not exposing the server to the network:

  1. On the remote machine, start JupyterLab as above and note the port and token in the output. By default it listens only on the local machine (localhost), which is what you want here.
  2. On your own computer, open a new terminal and connect to the remote machine with SSH, adding a local port forward from port 8888 on your computer to port 8888 on the remote machine’s localhost. If JupyterLab chose a different port, use that one.
  3. Keep that SSH session open. The forward lasts only as long as the connection.
  4. On your own computer, open a browser and go to localhost on port 8888. Use the URL with the token from the remote terminal, or enter the token or password on the login page. You should see the JupyterLab interface, running on the remote machine.

Do not expose the server to the internet without a password or token, because anyone who can reach it can run code as your user. Avoid making it listen on all network interfaces unless you have a strong reason, and never open its port in your firewall to the public. The forwarding method keeps all traffic inside the encrypted SSH connection and needs no firewall changes beyond SSH itself.

With JupyterLab in place, you can try out code, plot and inspect data, and share notebooks with colleagues. Notebooks are plain files, so they are easy to keep in version control or send to someone else.

Have a question about this guide?

Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.

Did this guide fix your problem?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *