[Python] Simple Python code to create Spark DataFrame always gave Python worker exited...

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Python 3.12.2, Java 11.0.24 and Spark 3.5.4

    from pyspark.sql import SparkSession
    spark = SparkSession.builder.getOrCreate()
    data = [("Alice", 25), ("Bob", 30)]
    df = spark.createDataFrame(data, ["name", "age"])
    df.show()


    Below is the output.

    C:\Users\reeve\PycharmProjects\CreateDataFrame-example01\.venv\Scripts\python.exe C:\Users\reeve\PycharmProjects\CreateDataFrame-example01\CreateDataFrame-example01.py
    Setting default log level to "WARN".
    To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
    25/01/17 10:26:02 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    25/01/17 10:26:21 ERROR Executor: Exception in task 0.0 in stage 0.0 (TID 0)
    org.apache.spark.SparkException: Python worker exited unexpectedly (crashed)
    at org.apache.spark.api.python.BasePythonRunner$ReaderIterator$$anonfun$1.applyOrElse(PythonRunner.scala:612)
    at org.apache.spark.api.python.BasePythonRunner$ReaderIterator$$anonfun$1.applyOrElse(PythonRunner.scala:594)
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:38)
    at org.apache.spark.api.python.PythonRunner$$anon$3.read(PythonRunner.scala:789)
    at org.apache.spark.api.python.PythonRunner$$anon$3.read(PythonRunner.scala:766)



    I upgraded the Spark from version 3.4.2 to 3.5.4 but it did not resolve the issue.

    Continue reading...

Compartilhe esta Página