cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting python version errors when using pyspark rdd using databricks connect

Surajv
New Contributor III

Hi community, 

When I use pyspark rdd related functions in my environment using databricks connect, I get below error: 

Databricks cluster version: 12.2. 

`RuntimeError: Python in worker has different version 3.9 than that in driver 3.10, PySpark cannot run with different minor versions. Please check environment variables PYSPARK PYTHON...`

How can I resolve it? 

2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @Surajv, The error message you’re encountering indicates a Python version mismatch between the Spark worker and the Spark driver.

To resolve this issue, follow these steps:

  1. Install Correct Python Version on Worker Node:

  2. Update Spark Configuration:

    • Edit or create the ./conf/spark-defaults.conf file (you can copy it from spark-defaults.conf.template) on both the master and worker nodes.
    • Add the following line to the configuration file:
      spark.pyspark.python /usr/bin/python3
      
    • Save the changes and restart both the master and worker nodes.
  3. Verify Environment Variables:

Surajv
New Contributor III

Got it. As a side note, I tried above methods, but the error persisted, hence upon reading docs again, there was this statement: You must install Python 3 on your development machine, and the minor version of your client Python installation must be the same as the minor Python version of your Databricks cluster. (Link: https://docs.databricks.com/en/dev-tools/databricks-connect-legacy.html#requirements). 

On aligning my environment python version with Databricks cluster python version, the error got resolved. 

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!