title: AttributeError: 'NoneType' object has no attribute 'sc'
body: <p>Excuse me.Today i want to run a program about how to create DataFrame with sqlContext in Pyspark.The result is a AttributeError,which is"AttributeError: 'NoneType' object has no attribute 'sc'"
    My computer is win7,spark's version is 1.6.0 ,and API is python3 .I had google several times and read the Spark Python API Docs,and can not solved the problems.So i look for your help.</p>
  
  <p>my code is that:</p>
  
  <pre><code>   #python version is 3.5
     sc.stop()
     import pandas as pd
     import numpy as np
     sc=SparkContext("local","app1"
     data2=[("a",5),("b",5),("a",5)]
     df=sqlContext.createDataFrame(data2)
  </code></pre>
  
  <p>And the result is that:</p>
  
  <hr>
  
  <pre><code>    AttributeError                            Traceback (most recent call last)
      &lt;ipython-input-19-030b8faadb2c&gt; in &lt;module&gt;()
      5 data2=[("a",5),("b",5),("a",5)]
      6 print(data2)
      ----&gt; 7 df=sqlContext.createDataFrame(data2)
  
      D:\spark\spark-1.6.0-bin-hadoop2.6\python\pyspark\sql\context.py in  createDataFrame(self, data, schema, samplingRatio)
      426             rdd, schema = self._createFromRDD(data, schema, samplingRatio)
      427         else:
      --&gt; 428             rdd, schema = self._createFromLocal(data, schema)
      429         jrdd = self._jvm.SerDeUtil.toJavaArray(rdd._to_java_object_rdd())
      430         jdf = self._ssql_ctx.applySchemaToPythonRDD(jrdd.rdd(), schema.json())
  
      D:\spark\spark-1.6.0-bin-hadoop2.6\python\pyspark\sql\context.py in _createFromLocal(self, data, schema)
     358         # convert python objects to sql data
     359         data = [schema.toInternal(row) for row in data]
     --&gt; 360         return self._sc.parallelize(data), schema
     361 
     362     @since(1.3)
  
      D:\spark\spark-1.6.0-bin-hadoop2.6\python\pyspark\context.py in parallelize(self, c, numSlices)
     410         [[], [0], [], [2], [4]]
     411         """
     --&gt; 412         numSlices = int(numSlices) if numSlices is not None else self.defaultParallelism
     413         if isinstance(c, xrange):
     414             size = len(c)
  
     D:\spark\spark-1.6.0-bin-hadoop2.6\python\pyspark\context.py in     defaultParallelism(self)
    346         reduce tasks)
    347         """
    --&gt; 348         return self._jsc.sc().defaultParallelism()
    349 
    350     @property
  
   AttributeError: 'NoneType' object has no attribute 'sc'
  </code></pre>
  
  <p>I am so fuzzed that i had created the "sc" in fact,why does it show the Error of"'NoneType' object has no attribute 'sc'"?</p>
  
  <p>​</p>