Install & Run the PySpark Notebooks

PySpark runs locally on your machine (no server, no Colab). Follow these steps once.

1. Prerequisites

Check versions:

python --version
java -version

2. Install dependencies

From the project root (where requirements.txt lives):

# (optional but recommended) create a virtual environment
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS / Linux:
source .venv/bin/activate

# install PySpark + Jupyter
pip install -r requirements.txt

requirements.txt contains: pyspark, jupyterlab.

3. Launch Jupyter and open a notebook

jupyter lab

This opens http://localhost:8888 in your browser. Then:

You'll see real PySpark output (runs in local mode — no cluster needed).

4. Verify PySpark works

In a notebook cell, run:

from pyspark.sql import SparkSession
spark = SparkSession.builder.master("local[*]").appName("test").getOrCreate()
df = spark.createDataFrame([(1, "alice"), (2, "bob")], ["id", "name"])
df.show()
spark.stop()

Troubleshooting

Related

SQL → PySpark live converter  ยท  Back to lessons