Running these seem to work:
# Download Java Virtual Machine (JVM)
!apt-get install openjdk-8-jdk-headless -qq > /dev/null
!wget -q https://dlcdn.apache.org/spark/spark-3.3.0/spark-3.3.0-bin-hadoop3.tgz
Then the following line does not work and produces this error:
!tar xf spark-3.3.0-bin-hadoop3.tgz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
When I do !pwd, I am in the same folder as where my spark-3.3.0-bin-hadoop3.tgz is located.
------------EDIT------------
For everyone else having this same error, forget the whole thing. There is a much easier way with 5 lines of code.
Run these instead and Pyspark should automatically be set up in Google Colab:
!pip install pyspark
# Import SparkSession
from pyspark.sql import SparkSession
# Create a Spark Session
spark = SparkSession.builder.master("local[*]").getOrCreate()
# Check Spark Session Information
spark
# Import a Spark function
from library from pyspark.sql.functions import col