Getting started
Choose a compatible environment
PySpark requires a compatible Java runtime as well as Python. Pin both in your project and check the compatibility table for the Spark version you choose. For example, PySparky Pipeline's current CI and local checks exercise CPython 3.10 and 3.11, PySpark 3.5.8, and Eclipse Temurin 17.0.21.1+2. That tested tuple describes Pipeline's checks; it is not a support claim for every PySparky repository.
Each library README states its own tested environment and installation instructions. The new PySparky package repositories are source-only at this time, so do not expect their distribution names to install from PyPI yet.
Create a small local project
With mise and uv installed, pin Python, Java, and uv in the project before creating the environment:
cat > mise.toml <<'EOF'
[tools]
java = "temurin-17.0.21.1+2"
python = "3.11.18"
uv = "0.13.10"
EOF
mise install java@temurin-17.0.21.1+2 python@3.11.18 uv@0.13.10
uv init --bare --python 3.11
uv add pyspark==3.5.8
Check the runtime versions before starting Spark:
uv run python --version
java -version
Run a DataFrame transformation
This example starts a local Spark session explicitly. The select call builds
a lazy DataFrame plan. show() is an action that evaluates the plan; stop()
closes the session.
from pyspark.sql import SparkSession, functions as F
spark = (
SparkSession.builder
.master("local[2]")
.appName("pysparky-getting-started")
.getOrCreate()
)
try:
result = spark.range(3).select((F.col("id") + 1).alias("next_id"))
result.show()
finally:
spark.stop()
Use native expressions such as pyspark.sql.functions where they express the
operation clearly. Keep actions such as show, count, collect, and writes
visible in application code because they start computation or return data to
the driver.