7  Jupyter Notebook

7.1 Install Jupyter Notebook

Inside your Python environment, install Jupyter Notebook:

python -m pip install notebook

Check that it was installed:

jupyter notebook --version

7.2 Install ipykernel

ipykernel allows a Python environment to be used as a kernel in Jupyter.

Install it with:

python -m pip install ipykernel

7.3 Register the environment as a Jupyter kernel

Run:

python -m ipykernel install --user --name my-environment --display-name "Python (my-environment)"

For example:

python -m ipykernel install --user --name data-analysis --display-name "Python (Data Analysis)"

The two names have different purposes:

  • --name: internal Jupyter kernel name.
  • --display-name: name shown in the Jupyter interface.

7.4 List available kernels

jupyter kernelspec list

Example:

Available kernels:
  python3          /home/user/.local/share/jupyter/kernels/python3
  data-analysis   /home/user/.local/share/jupyter/kernels/data-analysis

7.5 Check which Python the kernel is using

Inside a notebook cell:

import sys

sys.executable
'/home/isaias/analisis_datos/python_book/.venv/bin/python3'

Example output:

/home/user/project/.venv/bin/python

This is useful for checking that Jupyter is using the expected Python environment.


7.6 Check the active kernel

You can also inspect the Python version:

import sys

print(sys.version)
print(sys.executable)
3.12.3 (main, Jun 19 2026, 12:46:00) [GCC 13.3.0]
/home/isaias/analisis_datos/python_book/.venv/bin/python3

7.7 Remove a registered kernel

First list the kernels:

jupyter kernelspec list

Then remove one:

jupyter kernelspec uninstall data-analysis

Jupyter will ask for confirmation.


7.8 Typical setup

For an existing Python environment, the complete Jupyter setup is usually:

python -m pip install notebook ipykernel

Register the environment:

python -m ipykernel install --user \
    --name data-analysis \
    --display-name "Python (Data Analysis)"

Check it:

jupyter kernelspec list

Launch Jupyter:

jupyter notebook

Then select:

Python (Data Analysis)

as the notebook kernel.