title: PySpark: Not able to create SparkSession.(Java Gateway Error)
body: <p>I have installed PySpark on windows and was having no problem till yesterday. I am using <code>windows 10</code>, <code>PySpark version 2.3.3(Pre-build version)</code>, <code>java version "1.8.0_201"</code>. Yesterday when I tried creating a spark session, I ran into below error.</p>
  
  <pre><code>Exception                                 Traceback (most recent call last)
  &lt;ipython-input-2-a9ef4ac1a07d&gt; in &lt;module&gt;
  ----&gt; 1 spark = SparkSession.builder.appName("Hello").master("local").getOrCreate()
  
  C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\sql\session.py in getOrCreate(self)
      171                     for key, value in self._options.items():
      172                         sparkConf.set(key, value)
  --&gt; 173                     sc = SparkContext.getOrCreate(sparkConf)
      174                     # This SparkContext may be an existing one.
      175                     for key, value in self._options.items():
  
  C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in getOrCreate(cls, conf)
      361         with SparkContext._lock:
      362             if SparkContext._active_spark_context is None:
  --&gt; 363                 SparkContext(conf=conf or SparkConf())
      364             return SparkContext._active_spark_context
      365 
  
  C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
      127                     " note this option will be removed in Spark 3.0")
      128 
  --&gt; 129         SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
      130         try:
      131             self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,
  
  C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\context.py in _ensure_initialized(cls, instance, gateway, conf)
      310         with SparkContext._lock:
      311             if not SparkContext._gateway:
  --&gt; 312                 SparkContext._gateway = gateway or launch_gateway(conf)
      313                 SparkContext._jvm = SparkContext._gateway.jvm
      314 
  
  C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\java_gateway.py in launch_gateway(conf)
       44     :return: a JVM gateway
       45     """
  ---&gt; 46     return _launch_gateway(conf)
       47 
       48 
  
  C:\spark-2.3.3-bin-hadoop2.7\python\pyspark\java_gateway.py in _launch_gateway(conf, insecure)
      106 
      107             if not os.path.isfile(conn_info_file):
  --&gt; 108                 raise Exception("Java gateway process exited before sending its port number")
      109 
      110             with open(conn_info_file, "rb") as info:
  
  Exception: Java gateway process exited before sending its port number
  </code></pre>
  
  <p>I did check out the pyspark issues on github as well as stackoverflow answers realted to the same but the issue is not resolved. </p>
  
  <p>I did try out the below methods:</p>
  
  <p>1.) Tried uninstalling, installing and Changing the java installation directory. Currently, my java installation directory is <code>C:/Java/</code> . <a href="https://stackoverflow.com/questions/31841509/pyspark-exception-java-gateway-process-exited-before-sending-the-driver-its-po">Pyspark: Exception: Java gateway process exited before sending the driver its port number</a></p>
  
  <p>2.) Tried setting <code>PYSPARK_SUBMIT_ARGS</code>, but of no help.</p>
  
  <p>Please suggest me the possible resolutions.</p>