I am trying to setup pyspark locally
- I've initiated a spark session
- created a view named people
- tried to read the view via below command
spark.sql("Select * From people")
It throws the Py4j exception below; it seems like a version mismatch error:
Py4JError: An error occurred while calling o24.sql.
Trace:
py4j.Py4JException: Method sql([class java.lang.String, class [Ljava.lang.Object;]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
at py4j.Gateway.invoke(Gateway.java:274)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.ClientServerConnection.waitForCommands(ClientServerConnection.java:182)
at py4j.ClientServerConnection.run(ClientServerConnection.java:106)
at java.base/java.lang.Thread.run(Thread.java:1623)
- Spark version: 3.3.4
- Java version: 20.0.2
- Python: 3.11.5
- Pyspark: 3.5.0
- Py4j: 0.10.9.7
I've tried different versions of Pyspark and Py4j for compatibility but they didn't work.
I suggest you to try the approach in this question: Error : py4j.Py4JException: Method sql([class java.lang.String, class [Ljava.lang.Object;]) does not exist
The root cause of your error seems a mismatch between spark and pyspark.
I would do the following:
1. Install the same version of pyspark and spark:
2. Try your query again