You are currently viewing How do you exit or quit Spark Shell & PySpark?

To exit or quit the PySpark shell, you can use the exit(), quit() functions or Ctrl+z, these commands will close the PySpark shell and return you to the terminal or environment where you launched it.

To exit or quit from the Spark shell (spark-shell), you can use the :quit, :q or Ctrl+z, these commands will close the Spark shell and return you to the terminal or environment where you launched it.

1. Exit or Quit from Spark Shell

Like any other shell, spark-shell also provides a way to exit from the shell. When you are in spark shell type :quit to come out of the shell prompt.

spark shell exit

Alternatively, you can also use Ctrl+z to exit from the shell.

2. Exit or Quit from PySpark Shell

Similarly, to exit or quit from pyspark shell, you can use either quit() or exit() from shell prompt. Let’s launch the shell, run some examples, and exit from it.

pyspark shell exit

Alternatively, you can also try Ctrl+z to exit from the pyspark shell.

Conclusion

In summary, exiting the PySpark shell involves using the exit() or quit() functions, or pressing Ctrl+z. Similarly, in the Spark shell (spark-shell), you can exit by employing :quit, :q, or Ctrl+z. Executing any of these commands effectively shuts down the shell, returning you to the initial terminal or environment.

Happy Learning !!

Naveen Nelamali

Naveen Nelamali (NNK) is a Data Engineer with 20+ years of experience in transforming data into actionable insights. Over the years, He has honed his expertise in designing, implementing, and maintaining data pipelines with frameworks like Apache Spark, PySpark, Pandas, R, Hive and Machine Learning. Naveen journey in the field of data engineering has been a continuous learning, innovation, and a strong commitment to data integrity. In this blog, he shares his experiences with the data as he come across. Follow Naveen @ LinkedIn and Medium