<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to &amp;quot;Python versions in the Spark Connect client and server are different. &amp;quot; in UDF in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/how-to-quot-python-versions-in-the-spark-connect-client-and/m-p/121351#M10160</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/164556"&gt;@Dimitry&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The error you're seeing indicates that the Python version in your notebook (3.11) doesn't match the version used by Databricks Serverless, which is typically Python 3.12. Since Serverless environments use a fixed Python version, this mismatch can cause issues, and unfortunately, the server-side version can't be changed manually.&lt;BR /&gt;To fix this, you can try updating your notebook's environment to one that supports Python 3.12. Here's how:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Open the Environment side panel in your serverless notebook.&lt;/LI&gt;&lt;LI&gt;Look for and select a serverless environment version that includes Python 3.12, if available in your workspace.&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Tue, 10 Jun 2025 15:37:38 GMT</pubDate>
    <dc:creator>SP_6721</dc:creator>
    <dc:date>2025-06-10T15:37:38Z</dc:date>
    <item>
      <title>How to "Python versions in the Spark Connect client and server are different. " in UDF</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-quot-python-versions-in-the-spark-connect-client-and/m-p/121213#M10154</link>
      <description>&lt;P&gt;I've read all relevant articles but none have solution that I could understand. Sorry I'm new to it.&lt;/P&gt;&lt;P&gt;I have a simple UDF to demonstrate the problem:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;df = spark.createDataFrame([(1, 1.0, 'a'), (1, 2.0, 'b'), (2, 3.0, 'c'), (2, 5.0, 'd'), (2, 10.0, 'e')], ("id", "v", 'l'))

def subtract_mean(pdf: pd.DataFrame) -&amp;gt; pd.DataFrame:
l = pdf.to_dict(orient='records')
for rec in l: rec["result"] = {"timestamp": datetime.now}
return pd.DataFrame(l)

print(df.schema)

result_field_schema = StructType([
StructField("timestamp", DateType())
])

out_schema = StructType([x for x in df.schema.fields]).add(StructField('result', result_field_schema, True))

df.groupby("id").applyInPandas(subtract_mean, schema=out_schema).show()&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;It will throw exception&lt;/P&gt;&lt;P&gt;"Python versions in the Spark Connect client and server are different. "&lt;BR /&gt;2136 "To execute user-defined functions, client and server should have the "&lt;BR /&gt;(...)&lt;/P&gt;&lt;P&gt;This is happening in a brand new notebook with no YAML attached. I could not find how to set python version in YAML either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found that VS code commits this to the notebook (this is why I tried new one in the test), and this change also didn't change anything.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dimitry_0-1749435601522.png" style="width: 254px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/17403i371C7409D234C384/image-dimensions/254x193?v=v2" width="254" height="193" role="button" title="Dimitry_0-1749435601522.png" alt="Dimitry_0-1749435601522.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Version of the python in the notebook is nailed to 3.11&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import sys
print("Python version:", sys.version)
# Python version: 3.11.10 (main, Sep 7 2024, 18:35:41) [GCC 11.4.0]&lt;/LI-CODE&gt;&lt;P&gt;My understanding is that developers of Databricks can't release "serverless" with non-functional mis-versioning, so there has to be way around this.&lt;/P&gt;&lt;P&gt;Please advise how to get it working - i.e. running notebook on serverless with python code in UDF.&lt;BR /&gt;Note that my sample is to POC, in real there is a whole API call thing in there that I want to scale up.&lt;/P&gt;&lt;P&gt;Second note that I can run it in "personal compute". But I want to use serverless whereas possible as I don't have much workload for keeping a costly cluster and managing it. I have strict budgets.&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 02:20:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-quot-python-versions-in-the-spark-connect-client-and/m-p/121213#M10154</guid>
      <dc:creator>Dimitry</dc:creator>
      <dc:date>2025-06-09T02:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to "Python versions in the Spark Connect client and server are different. " in UDF</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-quot-python-versions-in-the-spark-connect-client-and/m-p/121351#M10160</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/164556"&gt;@Dimitry&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The error you're seeing indicates that the Python version in your notebook (3.11) doesn't match the version used by Databricks Serverless, which is typically Python 3.12. Since Serverless environments use a fixed Python version, this mismatch can cause issues, and unfortunately, the server-side version can't be changed manually.&lt;BR /&gt;To fix this, you can try updating your notebook's environment to one that supports Python 3.12. Here's how:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Open the Environment side panel in your serverless notebook.&lt;/LI&gt;&lt;LI&gt;Look for and select a serverless environment version that includes Python 3.12, if available in your workspace.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Tue, 10 Jun 2025 15:37:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-quot-python-versions-in-the-spark-connect-client-and/m-p/121351#M10160</guid>
      <dc:creator>SP_6721</dc:creator>
      <dc:date>2025-06-10T15:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to "Python versions in the Spark Connect client and server are different. " in UDF</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-quot-python-versions-in-the-spark-connect-client-and/m-p/121406#M10162</link>
      <description>&lt;P&gt;Hi mate&lt;/P&gt;&lt;P&gt;Whilst I understand what you are saying, I can't see how it can possibly work.&lt;/P&gt;&lt;P&gt;I get only 2 choices for the serverless environment version:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dimitry_0-1749598753917.png" style="width: 145px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/17438i77AA667650F65B50/image-dimensions/145x180?v=v2" width="145" height="180" role="button" title="Dimitry_0-1749598753917.png" alt="Dimitry_0-1749598753917.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and version 2 being the latest is python 3.11&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/release-notes/serverless/environment-version-two" target="_blank"&gt;Serverless environment version 2 - Azure Databricks | Microsoft Learn&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dimitry_1-1749598815511.png" style="width: 236px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/17439iD5164CFECB6A37DE/image-dimensions/236x105?v=v2" width="236" height="105" role="button" title="Dimitry_1-1749598815511.png" alt="Dimitry_1-1749598815511.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So there is no version to select for 3.12&lt;/P&gt;&lt;P&gt;Unless you are a bot (hard to tell these days), please explain how to do&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;UL&gt;&lt;LI&gt;Look for and select a serverless environment version that includes Python 3.12, if available in your workspace.&lt;/LI&gt;&lt;/UL&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 23:43:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-quot-python-versions-in-the-spark-connect-client-and/m-p/121406#M10162</guid>
      <dc:creator>Dimitry</dc:creator>
      <dc:date>2025-06-10T23:43:36Z</dc:date>
    </item>
  </channel>
</rss>

