方法 showString([class java.lang.Integer, class java.lang.Integer, class java.lang.Boolean]) 在 PySpark 中不存在 [英] Method showString([class java.lang.Integer, class java.lang.Integer, class java.lang.Boolean]) does not exist in PySpark

查看:27
本文介绍了方法 showString([class java.lang.Integer, class java.lang.Integer, class java.lang.Boolean]) 在 PySpark 中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是片段:

from pyspark import SparkContext
from pyspark.sql.session import SparkSession

sc = SparkContext()
spark = SparkSession(sc)
d = spark.read.format("csv").option("header", True).option("inferSchema", True).load('file.csv')
d.show()

在这运行到错误之后:

An error occurred while calling o163.showString. Trace:
py4j.Py4JException: Method showString([class java.lang.Integer, class java.lang.Integer, class java.lang.Boolean]) does not exist

所有其他方法都运行良好.尝试了很多研究,但徒劳无功.任何线索将不胜感激

All the other methods work well. Tried researching alot but in vain. Any lead will be highly appreciated

推荐答案

这是 Spark 版本不匹配的指标.之前的 Spark 2.3 show 方法只接受两个参数:

This is an indicator of a Spark version mismatch. Before Spark 2.3 show method took only two arguments:

def show(self, n=20, truncate=True):

因为 2.3三个参数:

def show(self, n=20, truncate=True, vertical=False):

在您的情况下,Python 客户端似乎调用了后者,而 JVM 后端使用的是旧版本.

In your case Python client seems to invoke the latter one, while the JVM backend uses the older version.

由于 SparkContext 初始化在 2.4 中发生了重大变化,这会导致 SparkContext.__init__ 失败,您可能会使用:

Since SparkContext initialization undergone significant changes in 2.4, which would cause failure on SparkContext.__init__, you're likely using:

  • 2.3.x Python 库.
  • 2.2.x JAR.

您可以通过直接从会话中检查版本来确认这一点,Python:

You can confirm that by checking versions directly from your session, Python:

sc.version

对比JVM:

sc._jsc.version()

像这样的问题,通常是由于 PYTHONPATH 配置错误(直接,或者通过使用 pip 安装了 PySpark 在每个现有的Spark 二进制文件)或 SPARK_HOME.

Problems like this, are usually a result of misconfigured PYTHONPATH (either directly, or by using pip installed PySpark on top per-existing Spark binaries) or SPARK_HOME.

这篇关于方法 showString([class java.lang.Integer, class java.lang.Integer, class java.lang.Boolean]) 在 PySpark 中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆