gpt4 book ai didi

java - 为什么 Spark 不能在 Eclipse 上运行?

转载 作者:可可西里 更新时间:2023-11-01 15:48:41 26 4
gpt4 key购买 nike

我已经使用 Python 3.7、JRE 8、JDK 1.8 在 Eclipse(Eclipse 插件:PyDev)上安装了带有 hadoop2.6 的 pysark2.1。

我正在尝试运行一个简单的测试代码:

from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()

但是我得到以下错误:

Using Spark's default log4j profile:
org/apache/spark/log4j-defaults.properties Setting default log level to "WARN". To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel). 18/12/30 17:04:33 ERROR SparkUncaughtExceptionHandler: Uncaught exception in thread Thread[main,5,main] java.util.NoSuchElementException: key not found: _PYSPARK_DRIVER_CALLBACK_HOST

at scala.collection.MapLike$class.default(MapLike.scala:228)
at scala.collection.AbstractMap.default(Map.scala:59)
at scala.collection.MapLike$class.apply(MapLike.scala:141)
at scala.collection.AbstractMap.apply(Map.scala:59)
at org.apache.spark.api.python.PythonGatewayServer$$anonfun$main$1.apply$mcV$sp(PythonGatewayServer.scala:50) at org.apache.spark.util.Utils$.tryOrExit(Utils.scala:1228)
at org.apache.spark.api.python.PythonGatewayServer$.main(PythonGatewayServer.scala:37) at org.apache.spark.api.python.PythonGatewayServer.main(PythonGatewayServer.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 org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738) at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187) at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212) at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126) at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

Traceback (most recent call last):

File "C:\Users\charfoush\eclipse-workspace\sample2\test2.py", line 7, in

spark = SparkSession.builder.getOrCreate()   

File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\sql\session.py", line 173, in getOrCreate

sc = SparkContext.getOrCreate(sparkConf)   

File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\context.py", line 351, in getOrCreate

SparkContext(conf=conf or SparkConf())   

File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\context.py", line 115, in init

SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)   

File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\context.py", line 300, in _ensure_initialized

SparkContext._gateway = gateway or launch_gateway(conf)   

File "C:\Users\charfoush\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyspark\java_gateway.py", line 93, in launch_gateway

raise Exception("Java gateway process exited before sending its port number") Exception: Java gateway process exited before sending

its port number

最佳答案

此问题可能会发生,例如:

  • 如果您的版本不匹配
  • 或者如果您没有正确定义 SPARK_HOMEPYTHONPATH 环境变量(确保它们都不是针对旧版本)

关于java - 为什么 Spark 不能在 Eclipse 上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53978806/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com