My guess is that the databricks environment is not yet fully initialized.
Sometimes you get the green traffic light in your notebook saying the cluster is online, but in fact it is still doing some stuff in the background (no idea what though).
So waiting a minute an try again works in most cases. If you keep on getting this error, a cluster restart may help.
Now, it could also be invalid code because of a version conflict in scala, python or spark.
Maybe you try to run python 2.x code on a 3.x cluster.