title: Unable to create spark session
body: <blockquote>
    <p>When I am creating a spark session, it is throwing an error</p>
  </blockquote>
  
  <ul>
  <li><p>Unable to create a spark session</p></li>
  <li><p>Using <code>pyspark</code>, the code snippet:</p></li>
  </ul>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-13-2262882856df&gt; in &lt;module&gt;()
       37 if __name__ == "__main__":
       38     conf = SparkConf()
  ---&gt; 39     sc = SparkContext(conf=conf)
       40 #     print(sc.version)
       41 #     sc = SparkContext(conf=conf)
  
  ~/anaconda3/lib/python3.5/site-packages/pyspark/context.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
      131                     " note this option will be removed in Spark 3.0")
      132 
  --&gt; 133         SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
      134         try:
      135             self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,
  
  ~/anaconda3/lib/python3.5/site-packages/pyspark/context.py in _ensure_initialized(cls, instance, gateway, conf)
      330                         " created by %s at %s:%s "
      331                         % (currentAppName, currentMaster,
  --&gt; 332                             callsite.function, callsite.file, callsite.linenum))
      333                 else:
      334                     SparkContext._active_spark_context = instance
  
  ValueError: Cannot run multiple SparkContexts at once; existing SparkContext(app=pyspark-shell, master=local[*]) created by __init__ at &lt;ipython-input-7-edf43bdce70a&gt;:33 
  
  </code></pre>
  
  <ul>
  <li><strong>imports</strong></li>
  </ul>
  
  <pre><code>
  from pyspark import SparkConf, SparkContext
  </code></pre>
  
  <ul>
  <li>I tried this alternative approach, which fails too:</li>
  </ul>
  
  <pre><code>spark = SparkSession(sc).builder.appName("Detecting-Malicious-URL App").getOrCreate()
  </code></pre>
  
  <p>This is throwing another error as follows:</p>
  
  <pre><code>NameError: name 'SparkSession' is not defined
  </code></pre>