I have installed pysark2.1 with hadoop2.6 on Eclipse (Eclipse plugins: PyDev) using Python 3.7, JRE 8, JDK 1.8.
I am trying to run a simple test code:
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
But I get the following error:
Using Spark's default log4j profile:
org/apache/spark/log4j-defaults.properties Setting default log level to "WARN". To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel). 18/12/30 17:04:33 ERROR SparkUncaughtExceptionHandler: Uncaught exception in thread Thread[main,5,main] java.util.NoSuchElementException: key not found: _PYSPARK_DRIVER_CALLBACK_HOSTat scala.collection.MapLike$class.default(MapLike.scala:228)
at scala.collection.AbstractMap.default(Map.scala:59)
at scala.collection.MapLike$class.apply(MapLike.scala:141)
at scala.collection.AbstractMap.apply(Map.scala:59)
at org.apache.spark.api.python.PythonGatewayServer$$anonfun$main$1.apply$mcV$sp(PythonGatewayServer.scala:50) at org.apache.spark.util.Utils$.tryOrExit(Utils.scala:1228)
at org.apache.spark.api.python.PythonGatewayServer$.main(PythonGatewayServer.scala:37) at org.apache.spark.api.python.PythonGatewayServer.main(PythonGatewayServer.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738) at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187) at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)Traceback (most recent call last):
File "C:\Users\charfoush\eclipse-workspace\sample2\test2.py", line 7, in
spark = SparkSession.builder.getOrCreate()
File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\sql\session.py", line 173, in getOrCreate
sc = SparkContext.getOrCreate(sparkConf)
File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\context.py", line 351, in getOrCreate
SparkContext(conf=conf or SparkConf())
File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\context.py", line 115, in init
SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\context.py", line 300, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway(conf)
File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\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