You have TensorFlow installed on your cluster.
When you try to import TensorFlow, it fails with an Invalid Syntax or import error.
The version of protobuf installed on your cluster is not compatible with your version of TensorFlow.
Use a cluster-scoped init script to install TensorFlow with matching versions of NumPy and protobuf.
- Create the init script.
%python dbutils.fs.put("/databricks/<init-script-folder>/install-tensorflow.sh",""" #!/bin/bash set -e /databricks/python/bin/python -V /databricks/python/bin/pip install tensorflow protobuf==3.17.3 numpy==1.15.0 """, True)
- Install the init script that you just created as a cluster-scoped init script (AWS | Azure | GCP).
You will need the full path to the location of the script (dbfs:/databricks/<init-script-folder>/install-tensorflow.sh).
- Restart the cluster after you have installed the init script.