Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-24739

PySpark does not work with Python 3.7.0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.1.3, 2.2.2, 2.3.1
    • 2.3.2, 2.4.0
    • PySpark
    • None

    Description

      Python 3.7 is released in few days ago and our PySpark does not work. For example

      sc.parallelize([1, 2]).take(1)
      
      File "/.../spark/python/pyspark/rdd.py", line 1343, in __main__.RDD.take
      Failed example:
          sc.parallelize(range(100), 100).filter(lambda x: x > 90).take(3)
      Exception raised:
          Traceback (most recent call last):
            File "/.../3.7/lib/python3.7/doctest.py", line 1329, in __run
              compileflags, 1), test.globs)
            File "<doctest __main__.RDD.take[2]>", line 1, in <module>
              sc.parallelize(range(100), 100).filter(lambda x: x > 90).take(3)
            File "/.../spark/python/pyspark/rdd.py", line 1377, in take
              res = self.context.runJob(self, takeUpToNumLeft, p)
            File "/.../spark/python/pyspark/context.py", line 1013, in runJob
              sock_info = self._jvm.PythonRDD.runJob(self._jsc.sc(), mappedRDD._jrdd, partitions)
            File "/.../spark/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in __call__
              answer, self.gateway_client, self.target_id, self.name)
            File "/.../spark/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value
              format(target_id, ".", name), value)
          py4j.protocol.Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.runJob.
          : org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 143.0 failed 1 times, most recent failure: Lost task 0.0 in stage 143.0 (TID 688, localhost, executor driver): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
            File "/.../spark/python/pyspark/rdd.py", line 1373, in takeUpToNumLeft
              yield next(iterator)
          StopIteration
      
          The above exception was the direct cause of the following exception:
      
          Traceback (most recent call last):
            File "/.../spark/python/lib/pyspark.zip/pyspark/worker.py", line 320, in main
              process()
            File "/.../spark/python/lib/pyspark.zip/pyspark/worker.py", line 315, in process
              serializer.dump_stream(func(split_index, iterator), outfile)
            File "/.../spark/python/lib/pyspark.zip/pyspark/serializers.py", line 378, in dump_stream
              vs = list(itertools.islice(iterator, batch))
          RuntimeError: generator raised StopIteration
      
          	at org.apache.spark.api.python.BasePythonRunner$ReaderIterator.handlePythonException(PythonRunner.scala:309)
          	at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRunner.scala:449)
          	at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRunner.scala:432)
          	at org.apache.spark.api.python.BasePythonRunner$ReaderIterator.hasNext(PythonRunner.scala:263)
          	at org.apache.spark.InterruptibleIterator.hasNext(InterruptibleIterator.scala:37)
          	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
          	at org.apache.spark.InterruptibleIterator.foreach(InterruptibleIterator.scala:28)
          	at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:59)
          	at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:104)
          	at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:48)
          	at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:310)
          	at org.apache.spark.InterruptibleIterator.to(InterruptibleIterator.scala:28)
          	at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:302)
          	at org.apache.spark.InterruptibleIterator.toBuffer(InterruptibleIterator.scala:28)
          	at scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:289)
          	at org.apache.spark.InterruptibleIterator.toArray(InterruptibleIterator.scala:28)
          	at org.apache.spark.api.python.PythonRDD$$anonfun$3.apply(PythonRDD.scala:149)
          	at org.apache.spark.api.python.PythonRDD$$anonfun$3.apply(PythonRDD.scala:149)
          	at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2071)
          	at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2071)
          	at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
          	at org.apache.spark.scheduler.Task.run(Task.scala:109)
          	at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:367)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
      
          Driver stacktrace:
          	at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1607)
          	at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1595)
          	at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1594)
          	at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
          	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
          	at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1594)
          	at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:831)
          	at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:831)
          	at scala.Option.foreach(Option.scala:257)
          	at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:831)
          	at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1828)
          	at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1777)
          	at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1766)
          	at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:49)
          	at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:642)
          	at org.apache.spark.SparkContext.runJob(SparkContext.scala:2031)
          	at org.apache.spark.SparkContext.runJob(SparkContext.scala:2052)
          	at org.apache.spark.SparkContext.runJob(SparkContext.scala:2071)
          	at org.apache.spark.api.python.PythonRDD$.runJob(PythonRDD.scala:149)
          	at org.apache.spark.api.python.PythonRDD.runJob(PythonRDD.scala)
          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
          	at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
          	at py4j.Gateway.invoke(Gateway.java:282)
          	at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
          	at py4j.commands.CallCommand.execute(CallCommand.java:79)
          	at py4j.GatewayConnection.run(GatewayConnection.java:238)
          	at java.lang.Thread.run(Thread.java:748)
          Caused by: org.apache.spark.api.python.PythonException: Traceback (most recent call last):
            File "/.../spark/python/pyspark/rdd.py", line 1373, in takeUpToNumLeft
              yield next(iterator)
          StopIteration
      
          The above exception was the direct cause of the following exception:
      
          Traceback (most recent call last):
            File "/.../spark/python/lib/pyspark.zip/pyspark/worker.py", line 320, in main
              process()
            File "/.../spark/python/lib/pyspark.zip/pyspark/worker.py", line 315, in process
              serializer.dump_stream(func(split_index, iterator), outfile)
            File "/.../spark/python/lib/pyspark.zip/pyspark/serializers.py", line 378, in dump_stream
              vs = list(itertools.islice(iterator, batch))
          RuntimeError: generator raised StopIteration
      
          	at org.apache.spark.api.python.BasePythonRunner$ReaderIterator.handlePythonException(PythonRunner.scala:309)
          	at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRunner.scala:449)
          	at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRunner.scala:432)
          	at org.apache.spark.api.python.BasePythonRunner$ReaderIterator.hasNext(PythonRunner.scala:263)
          	at org.apache.spark.InterruptibleIterator.hasNext(InterruptibleIterator.scala:37)
          	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
          	at org.apache.spark.InterruptibleIterator.foreach(InterruptibleIterator.scala:28)
          	at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:59)
          	at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:104)
          	at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:48)
          	at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:310)
          	at org.apache.spark.InterruptibleIterator.to(InterruptibleIterator.scala:28)
          	at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:302)
          	at org.apache.spark.InterruptibleIterator.toBuffer(InterruptibleIterator.scala:28)
          	at scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:289)
          	at org.apache.spark.InterruptibleIterator.toArray(InterruptibleIterator.scala:28)
          	at org.apache.spark.api.python.PythonRDD$$anonfun$3.apply(PythonRDD.scala:149)
          	at org.apache.spark.api.python.PythonRDD$$anonfun$3.apply(PythonRDD.scala:149)
          	at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2071)
          	at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2071)
          	at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
          	at org.apache.spark.scheduler.Task.run(Task.scala:109)
          	at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:367)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	... 1 more
      

      Should check the behaviour changes or bugs in Python and PySpark.

      Attachments

        Activity

          People

            gurwls223 Hyukjin Kwon
            gurwls223 Hyukjin Kwon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: