Home > Software design >  Creating sparkContext on Google Colab gives: `RuntimeError: Java gateway process exited before sendi
Creating sparkContext on Google Colab gives: `RuntimeError: Java gateway process exited before sendi

Time:01-03

Following are the dependencies, which got installed successfully.

!apt-get install openjdk-8-jre
!apt-get install scala
!pip install py4j
!wget -q https://downloads.apache.org/spark/spark-2.4.8/spark-2.4.8-bin-hadoop2.7.tgz
!tar xf spark-2.4.8-bin-hadoop2.7.tgz
!pip install -q findspark

Now to create the spark context:

# Setting up environment variables
import os
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64"
os.environ["SPARK_HOME"] = "/content/spark-2.4.8-bin-hadoop2.7"
# export PYSPARK_SUBMIT_ARGS ="--master local[2]"

# Importing and initating spark
import findspark
findspark.init()
from pyspark.sql import SparkSession
spark = SparkSession.builder.master("local[*]").appName("Test Setup").getOrCreate()
sc = spark.sparkContext

I'm getting this error:

RuntimeError: Java gateway process exited before sending its port number

Please note that this is a colab notebook. Any kind of help would be great.

CodePudding user response:

You can install enter image description here

  • Related