How to Set Up a Python Notebook: A Step-by-Step Beginner Guide

Jupyter Notebooks are one of the most popular tools for data analysis in Python. They let you write code, see results, and add notes all in one place - which makes them ideal for exploring data. This guide walks you through setting everything up from scratch, even if you have never written a line of Python before.

What You Will Need

  • A Windows, Mac, or Linux computer
  • An internet connection for the downloads
  • About 15 minutes

Step 1 - Install Python

Go to python.org/downloads and download the latest stable version (3.11 or higher). Run the installer.

Important - on Windows, tick the box that says Add Python to PATH before clicking Install Now. If you miss this, Python commands will not work in the terminal.

To confirm Python installed correctly, open a terminal (Command Prompt on Windows, Terminal on Mac/Linux) and run:

python --version

You should see something like Python 3.12.1.

Step 2 - Create a Project Folder

It is good practice to keep each project in its own folder with its own isolated environment. Create a folder somewhere on your computer, for example:

mkdir my_data_project
cd my_data_project

Step 3 - Create a Virtual Environment

A virtual environment keeps your project's packages separate from the rest of your computer. Run this inside your project folder:

python -m venv venv

Then activate it:

# Windows
venv\Scripts\activate

# Mac / Linux
source venv/bin/activate

You will see (venv) appear at the start of your terminal prompt. This means your environment is active.

Step 4 - Install Jupyter and pandas

With your environment active, install the key packages:

pip install jupyter pandas

This installs Jupyter (the notebook interface) and pandas (the main library for working with data in Python). Installation takes a minute or two.

Step 5 - Launch Jupyter Notebook

Start the notebook server:

jupyter notebook

This opens a browser window showing your project folder. Click New > Python 3 (ipykernel) to create your first notebook.

Step 6 - Write Your First Code

In the notebook, click inside a cell and type:

import pandas as pd

data = {
    'product':  ['Shoes', 'Jacket', 'Bag', 'Hat'],
    'price':    [89.99, 124.00, 45.50, 22.00],
    'in_stock': [True, False, True, True],
}

df = pd.DataFrame(data)
print(df)

Press Shift + Enter to run the cell. You will see your data printed as a table. That is your first DataFrame - the core building block of data analysis in Python.

Step 7 - Using VS Code Instead (Optional)

Many analysts prefer VS Code over the browser-based Jupyter interface. To use notebooks in VS Code:

  • Download VS Code from code.visualstudio.com.
  • Install the Python extension from the Extensions panel.
  • Open your project folder in VS Code.
  • Create a new file with a .ipynb extension.
  • VS Code will detect it as a notebook and show the same cell interface.

VS Code also has better autocomplete and integrates well with Git, making it the better long-term choice for most analysts.

Common Issues and Fixes

  • 'python' is not recognised: Python was not added to PATH. Reinstall and tick the Add to PATH box, or search 'edit environment variables' in Windows and add Python manually.
  • Jupyter command not found: Make sure your virtual environment is activated before running pip install or jupyter.
  • Kernel keeps dying: This usually means you are running out of memory on large datasets. Try reading a smaller sample first with pd.read_csv('file.csv', nrows=1000).
  • ModuleNotFoundError for pandas: You probably installed pandas outside the virtual environment. Activate venv first, then run pip install pandas again.

What to Do Next

With your notebook running, the next step is learning pandas - how to load data, filter rows, group by categories, and calculate aggregates. These are the four skills that make up most real data analysis work.

Try it yourself

Start with Level 1: print(), in your browser.

The first 5 levels are free · no sign-up needed