'SparkSession' object has no attribute 'sparkContext'
<p>I have Spark 2.0.0 and I am trying to run some Python examples from Spark source code.</p>

<p>This is the <a href="https://github.com/apache/spark/blob/master/examples/src/main/python/pi.py" rel="nofollow">example</a>. And I was running like:</p>

<pre><code>spark-submit pi.py 2
</code></pre>

<p>But I kept getting the following error:</p>

<pre><code>Traceback (most recent call last):
  File "/home/docker-user/src/hellospark/src/main/python/pi.py", line 21, in &lt;module&gt;
    count = ss.sparkContext.parallelize(range(1, n + 1), partitions).map(f).reduce(add)
AttributeError: 'SparkSession' object has no attribute 'sparkContext'
</code></pre>

<p>I've also tested with other examples like wordcount.py, sort.py and sql.py, all of them works as expected. Anybody has met this issue before? Any comment would be super helpful.</p>

<p>Thanks in advance!!  </p>