Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 39 ยท Getting Started

Installing and Launching Jupyter

Install Jupyter Notebook and JupyterLab with pip in a virtual environment, or with conda, then start the server, open the browser and stop it safely.

You can start using Jupyter in about five minutes. There are two common routes: install it with pip inside a Python virtual environment, or install a distribution such as Anaconda or Miniconda that manages environments with conda. A third route needs no installation at all: hosted notebooks (services such as Google Colab and Binder run the notebook in the cloud for you).

Jupyter cannot run on this website, so the commands below are shown as read-only code. Run them in a terminal on your own machine. The runnable examples are stand-ins that build the same commands or check the same facts in Python.

Before you start: Python and environments

Jupyter needs Python 3. Check that you have it:

Terminal
python --version      # on Windows you may need: py --version

If that prints a version such as 3.12.x, you are ready. The best habit is to create one virtual environment per project so that libraries from different projects never clash. An environment is a private folder that holds its own copy of Python packages.

Route 1: pip and a virtual environment

On macOS and Linux:

Terminal
mkdir my-notebooks
cd my-notebooks
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install jupyterlab notebook

On Windows (PowerShell):

Terminal
mkdir my-notebooks
cd my-notebooks
py -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install jupyterlab notebook

After activation, the terminal prompt usually shows (.venv). Everything you install with python -m pip now goes into that folder only. Installing jupyterlab pulls in the server, the kernel for Python (ipykernel) and the interface. Installing notebook adds the classic Notebook app as well; you may install only one if you prefer.

Always write python -m pip instead of plain pip. It guarantees that the pip you call belongs to the same Python you are about to use.

Route 2: conda

Anaconda and Miniconda include their own package manager. Create an environment and add Jupyter to it:

Terminal
conda create --name notebooks python=3.12
conda activate notebooks
conda install jupyterlab notebook

Conda is popular in data science because it also installs non-Python libraries that scientific packages need. Many people use the community channel conda-forge (conda install -c conda-forge jupyterlab). Do not mix many pip and conda installs in the same environment unless you must; prefer one tool per environment.

Launching the server

Start the interface you want, from the folder that contains your notebooks:

Terminal
jupyter lab        # opens JupyterLab
jupyter notebook   # opens the classic Notebook app

The command starts the Jupyter Server and prints something like a local address with a long token, for example http://localhost:8888/lab?token=.... Your default browser opens that address. Notice three facts:

  • The server runs on your machine. Nothing is uploaded anywhere.
  • The address uses localhost and a port (default 8888; if it is busy Jupyter picks 8889 and so on).
  • The token is a password that protects the server so other programs and users on the network cannot run code as you. Do not share the full URL.

You can change the port or skip auto-opening the browser:

Terminal
jupyter lab --port 9000 --no-browser

The terminal where you started the server must stay open. It prints log messages, including kernel start-ups and errors. In the browser you work with notebooks; in the terminal you see the plumbing.

flowchart TD
    A["Create environment"] --> B["Install jupyterlab"]
    B --> C["Run: jupyter lab"]
    C --> D["Server starts on localhost:8888"]
    D --> E["Browser opens with a token"]
    E --> F["Create or open .ipynb notebooks"]

From an empty folder to a notebook: the whole set-up path.

Stopping the server

There are two clean ways to stop it:

  1. In the terminal where it runs, press Ctrl+C, then confirm with y when asked.
  2. In JupyterLab use the menu File โ†’ Shut Down; in the classic Notebook use the Quit button on the file list page.

Closing only the browser tab does not stop the server or the kernels. Forgotten servers keep using memory. To list running servers, run jupyter server list in a terminal.

Where do the files live?

Jupyter shows the folder you started it in as its root. It will not let you browse above it, so start it from your projects folder, not from your home directory root, if you want a tidy view. Notebooks you create are saved as .ipynb files in the folder you are looking at, right next to your data and scripts.

Helpful stand-ins

The first stand-in builds the exact commands for your system, so you can see how the pieces fit together:

Python Stand-in: build the setup commands

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second stand-in explains the "address and token" idea by parsing a server URL the way you would read it:

Python Stand-in: read a Jupyter server URL

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Troubleshooting

Symptom Likely cause and fix
jupyter: command not found The environment is not activated, or Jupyter is not installed in it. Activate it and run python -m pip install jupyterlab.
python -m jupyter works but jupyter does not The scripts folder is not on PATH. Use python -m jupyterlab as a workaround.
Browser shows "Token required" Copy the full URL from the terminal, or set a password with jupyter server password.
Port already in use Use --port 8890, or stop the other server.
Imports fail inside the notebook The kernel uses a different Python than the one you installed into. See Kernels explained.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why create a virtual environment for each project?

    An environment isolates packages per project, avoiding version clashes between projects.
  2. 2. Which command starts JupyterLab?

    jupyter lab starts the server and opens the JupyterLab interface in your browser.
  3. 3. You close the browser tab. What happens to the server?

    The server is a separate process. Stop it with Ctrl+C in its terminal or File, Shut Down in JupyterLab.
  4. 4. What is the token in the Jupyter URL for?

    The token acts as a password for the local server, so others on the network cannot execute code through it.

Summary

  • Install Jupyter inside a virtual environment (python -m venv) or a conda environment.
  • Use python -m pip install jupyterlab notebook to get the interfaces and the Python kernel.
  • jupyter lab or jupyter notebook starts a local server on a port such as 8888 and opens your browser.
  • The URL token protects the server; keep it private.
  • Stop the server with Ctrl+C or File, Shut Down; closing the tab is not enough.
  • Start the server from your project folder, since it only shows files below that folder.

Next: The notebook interface