gpt4 book ai didi

apache-spark - 如何在 Spark 2.0 程序(实际上是 pyspark 2.0)中编写正确的入口点?

转载 作者:行者123 更新时间:2023-12-04 05:17:10 24 4
gpt4 key购买 nike

今天,我想尝试一些 Spark2.0 的新功能,这是我的程序:

#coding:utf-8
from pyspark.conf import SparkConf
from pyspark.sql import SparkSession

spark = SparkSession.builder.master("local").appName('test 2.0').config(conf=SparkConf()).getOrCreate()
df = spark.read.json("/Users/lyj/Programs/Apache/Spark2/examples/src/main/resources/people.json")
df.show()

但它错误如下:
Traceback (most recent call last):
File "/Users/lyj/Programs/kiseliugit/MyPysparkCodes/test/spark2.0.py", line 5, in <module>
spark = SparkSession.builder.master("local").appName('test 2.0').config(conf=SparkConf()).getOrCreate()
File "/Users/lyj/Programs/Apache/Spark2/python/pyspark/conf.py", line 104, in __init__
SparkContext._ensure_initialized()
File "/Users/lyj/Programs/Apache/Spark2/python/pyspark/context.py", line 243, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway()
File "/Users/lyj/Programs/Apache/Spark2/python/pyspark/java_gateway.py", line 116, in launch_gateway
java_import(gateway.jvm, "org.apache.spark.SparkConf")
File "/Library/Python/2.7/site-packages/py4j/java_gateway.py", line 90, in java_import
return_value = get_return_value(answer, gateway_client, None, None)
File "/Library/Python/2.7/site-packages/py4j/protocol.py", line 306, in get_return_value
value = OUTPUT_CONVERTER[type](answer[2:], gateway_client)
KeyError: u'y'

这几行代码有什么问题?是不是java环境有问题?另外,我使用 IDE PyCharm 进行开发。

最佳答案

尝试升级py4j,pip install py4j --upgrade

它对我有用。

关于apache-spark - 如何在 Spark 2.0 程序(实际上是 pyspark 2.0)中编写正确的入口点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38637988/

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