I followed these instructions and installed Apache Spark (PySpark) 2.3.1 on my machine which has the specifications:
- Ubuntu 18.04
- JDK 10
- Python 3.6
When I create a SparkSession
either indirectly by calling pyspark
from the shell or by directly creating a session in my app with:
spark = pyspark.sql.SparkSession.builder.appName('test').getOrCreate()
I get the following exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:80)
at org.apache.hadoop.security.SecurityUtil.getAuthenticationMethod(SecurityUtil.java:611)
at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:273)
....
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:137)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3107)
at java.base/java.lang.String.substring(String.java:1873)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:52)
... 22 more
Traceback (most recent call last):
File "/home/welshamy/tools/anaconda3/lib/python3.6/site-packages/pyspark/python/pyspark/shell.py", line 38, in <module>
SparkContext._ensure_initialized()
File "/home/welshamy/tools/anaconda3/lib/python3.6/site-packages/pyspark/context.py", line 292, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway(conf)
File "/home/welshamy/tools/anaconda3/lib/python3.6/site-packages/pyspark/java_gateway.py", line 93, in launch_gateway
raise Exception("Java gateway process exited before sending its port number")
Exception: Java gateway process exited before sending its port number
If I'm using a Jupyter notebook, I also get this exception in the notebook:
Exception: Java gateway process exited before sending the driver its port number
All the solutions I found and followed [1,2,3] point toward environment variables definitions, but non of them worked for me.