【问题标题】:Pyspark: Error -- Java gateway process exited before sending the driver its port numberPyspark:错误——Java 网关进程在向驱动程序发送其端口号之前退出
【发布时间】:2017-07-15 22:49:14
【问题描述】:

当我尝试在 Pyspark 中实例化 Spark 会话时,我收到此错误:Exception: Java gateway process exited before sending the driver its port number。这是代码

from pyspark import SparkConf
from pyspark.sql import SparkSession

if __name__ == '__main__':
    SPARK_CONFIGURATION = SparkConf().setAppName("OPL").setMaster("local[*]")
    SPARK_SESSION = SparkSession.builder\
        .config(conf=SPARK_CONFIGURATION)\
        .getOrCreate()

    print("Hello world")

这是回溯

Neon was unexpected at this time.
Traceback (most recent call last):
  File "C:\Users\IBM_ADMIN\Documents\Eclipse Neon for Liberty on Bluemix\OPL_Interface\src\Test\SparkTest.py", line 12, in <module>
    .config(conf=SPARK_CONFIGURATION)\
  File "C:\Users\IBM_ADMIN\Documents\spark-2.1.0-bin-hadoop2.7\python\pyspark\sql\session.py", line 169, in getOrCreate
    sc = SparkContext.getOrCreate(sparkConf)
  File "C:\Users\IBM_ADMIN\Documents\spark-2.1.0-bin-hadoop2.7\python\pyspark\context.py", line 307, in getOrCreate
    SparkContext(conf=conf or SparkConf())
  File "C:\Users\IBM_ADMIN\Documents\spark-2.1.0-bin-hadoop2.7\python\pyspark\context.py", line 115, in __init__
    SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
  File "C:\Users\IBM_ADMIN\Documents\spark-2.1.0-bin-hadoop2.7\python\pyspark\context.py", line 256, in _ensure_initialized
    SparkContext._gateway = gateway or launch_gateway(conf)
  File "C:\Users\IBM_ADMIN\Documents\spark-2.1.0-bin-hadoop2.7\python\pyspark\java_gateway.py", line 95, in launch_gateway
    raise Exception("Java gateway process exited before sending the driver its port number")
Exception: Java gateway process exited before sending the driver its port number

我将 PyDev 与 Eclipse Eclipse Neon.2 Release (4.6.2) 一起使用。这是配置: Libraries Environment

注意:我使用的是最新的 Spark 版本:spark-2.1.0-bin-hadoop2.7

我检查了其他几个条目 Pyspark: Exception: Java gateway process exited before sending the driver its port number Spark + Python - Java gateway process exited before sending the driver its port number? 并尝试了大多数建议的修复程序,但错误仍然存​​在。这对我来说是个障碍,因为在获得 SparkSession 之前我无法测试我的代码。顺便说一句,我也在使用 Java 中的 Spark,但那里没有同样的问题。

这是 Pyspark 中的错误吗?

【问题讨论】:

  • 我有同样的错误。虽然只有一个笔记本。我可以在一个笔记本中运行 spark,而在另一个笔记本中出现错误。虽然,两个笔记本都执行相同的代码...

标签: pyspark


【解决方案1】:

我和我的同事也都遇到了同样的问题,这阻碍了我们,让我们把头发拉了一段时间。我们尝试了一堆建议(Java 路径中没有空格,设置/取消设置 PYSPARK_SUBMIT_ARGS env var,...)都无济于事。

为我们解决这个问题的是切换到 Spark 2.3.1。我们正在尝试使用 2.2.1 和 2.3.0。

希望这可以帮助一些人省去一些麻烦。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-28
    • 2018-09-12
    • 2019-08-13
    • 2015-10-27
    • 2021-09-15
    • 1970-01-01
    相关资源
    最近更新 更多