To check the Python version in Databricks, you can use the following methods:
-
Using
sys.version
:pythonimport sys
print(sys.version)
This will display the full Python version information1.
-
Using shell command:
text%sh python --version
This command will show the Python version installed on the cluster1.
-
Checking cluster configuration:
Navigate to Cluster –> SparkUI –> Environment to see the cluster’s Python version1.
It’s important to note that the Python version displayed in the cluster configuration might not always reflect the version used in your notebooks. The version used in notebooks is typically determined by the PYSPARK_PYTHON environment variable1.
Version Information
-
For recent Databricks Runtime versions:
-
For older Databricks Runtime versions:
-
Databricks Runtime 12.2 LTS uses Python 3.9
-
Databricks Runtime 11.3 LTS uses Python 3.9
-
Databricks Runtime 10.4 LTS uses Python 3.8
-
Databricks Runtime 9.1 LTS uses Python 3.8
-
Databricks Runtime 7.3 LTS uses Python 3.75
-
It’s crucial to ensure that your local Python version matches the version used in your Databricks environment, especially when using features like Databricks Connect or working with user-defined functions (UDFs)24.