[Python] 'SparkSession' object has no attribute 'sparkContext'

Discussão em 'Python' iniciado por Stack, Fevereiro 25, 2025.

  1. Stack

    Stack Membro Participativo

    I have Spark 2.0.0 and I am trying to run some Python examples from Spark source code.

    This is the example. And I was running like:

    spark-submit pi.py 2


    But I kept getting the following error:

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


    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.

    Thanks in advance!!

    Continue reading...

Compartilhe esta Página