:“function”对象在 jupyter 上没有属性“read”

Sah*_*adi 3 python apache-spark pyspark jupyter

我在上传数据集时遇到错误,它显示错误 AttributeError: 'function' object has no attribute 'read' 我在 jupyter 这是我的输出 1

mck*_*mck 5

线路

spark = SparkSession.builder.master("local").name("test").getOrCreate
Run Code Online (Sandbox Code Playgroud)

将函数 分配getOrCreate给变量spark,这不是您想要的。

相反,您希望将函数(即 Spark 会话)的返回值getOrCreate分配给变量spark,因此您需要使用一对空括号来调用该函数:

spark = SparkSession.builder.master("local").name("test").getOrCreate()
Run Code Online (Sandbox Code Playgroud)