【发布时间】:2021-01-29 20:11:27
【问题描述】:
当我尝试运行 sc = SparkContext(appName="exampleName") 时,我已将整个错误包含在下面:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sharan/.local/lib/python3.5/site-packages/pyspark/context.py", line 118, in __init__
conf, jsc, profiler_cls)
File "/home/sharan/.local/lib/python3.5/site-packages/pyspark/context.py", line 188, in _do_init
self._javaAccumulator = self._jvm.PythonAccumulatorV2(host, port)
File "/home/sharan/.local/lib/python3.5/site-packages/py4j/java_gateway.py", line 1525, in __call__
answer, self._gateway_client, None, self._fqn)
File "/home/sharan/.local/lib/python3.5/site-packages/py4j/protocol.py", line 332, in get_return_value
format(target_id, ".", name, value))
py4j.protocol.Py4JError: An error occurred while calling None.org.apache.spark.api.python.PythonAccumulatorV2. Trace:
py4j.Py4JException: Constructor org.apache.spark.api.python.PythonAccumulatorV2([class java.lang.String, class java.lang.Integer]) does not exist
at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:179)
at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:196)
at py4j.Gateway.invoke(Gateway.java:237)
at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:80)
at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:69)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.lang.Thread.run(Thread.java:748)
我不知道如何调试它。有没有我可以访问的日志?我是否缺少我应该在我的 ubuntu 计算机上安装的特定软件包?
【问题讨论】:
-
你是从
pyspark命令行运行这个吗?如果是这样,那么您不能这样做,因为当您进入 pyspark shell 时,会使用其默认值初始化 sparkcontext,并且 spark 不允许为单个驱动程序运行多个sparkcontext。 -
@MdShihabUddin 我将其作为 python3 程序运行
-
似乎您混合了不兼容的 Java 和 Python 代码版本。这通常发生在您使用
pip(或类似工具)安装pyspark与实际的Spark 安装无关,或者您有多个Spark 版本,以及错误配置的Python 搜索路径或SPARK_HOME。 -
这里有一个类似的问题:stackoverflow.com/questions/52646868/…
标签: python apache-spark ubuntu pyspark