You can follow the below steps:
Change the working dir in order to set the checkpoint dir with sc.setCheckpointDir():
!pwd
Next, create a directory on that route:
!mkdir <pwd_output>/checkpoints
Set the checkpoint:
spark.sparkContext.setCheckpointDir('<pwd_output>/checkpoints')
After that it will work.
To know more about it, get your PySpark Certification today and become expert.
Thanks.