Brothers , this error has bothered me for one week and made me go crazy.But atleast i had one hor trouble shooting session with chatgpt and fix this. So this is what happened and it's so freakin' silly. I had a folder called pyspark.py in my working directing and the "from pyspark.sql import bla bla bla' was referencing to the pyspark.py file in my working directory rather than the installed pyspark library . i removed the filed , removed "pycache" file and removed the cache again through python command . Then exit working directory and create a new clean directory and run your code again . This should do the trick. This is my first contribution . Thanks fellas**