<?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: Why am I getting NameError name _all_timezones_unchecked' is not defined in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133203#M49741</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/173840"&gt;@Khaja_Zaffer&lt;/a&gt;, thank you for being willing to reply to my post I have initiated the function on the 2nd cell, and this problem only appears occasionally, and I am using General Compute&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgusBudianto_2-1759107496030.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20280i819691C9C48CF8E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgusBudianto_2-1759107496030.png" alt="AgusBudianto_2-1759107496030.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;error&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgusBudianto_1-1759107481234.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20279i4C53F3204B7F9F4A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgusBudianto_1-1759107481234.png" alt="AgusBudianto_1-1759107481234.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgusBudianto_3-1759107520702.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20281i2B59EDDE3D1EAC7E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgusBudianto_3-1759107520702.png" alt="AgusBudianto_3-1759107520702.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;in function I have using library:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; datetime &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; datetime, timedelta&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; pytz&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Thank's&lt;/P&gt;&lt;P&gt;Anto&lt;/P&gt;</description>
    <pubDate>Mon, 29 Sep 2025 01:00:59 GMT</pubDate>
    <dc:creator>AgusBudianto</dc:creator>
    <dc:date>2025-09-29T01:00:59Z</dc:date>
    <item>
      <title>Why am I getting NameError name _all_timezones_unchecked' is not defined</title>
      <link>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133153#M49735</link>
      <description>&lt;P&gt;I defined the following local time function &lt;SPAN&gt;get datetime&lt;/SPAN&gt;:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;def&lt;/SPAN&gt; &lt;SPAN&gt;get_sysdate&lt;/SPAN&gt;&lt;SPAN&gt;():&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; jkt_tz &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; pytz.&lt;/SPAN&gt;&lt;SPAN&gt;timezone&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Asia/Jakarta'&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; sysdate &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; datetime.&lt;/SPAN&gt;&lt;SPAN&gt;now&lt;/SPAN&gt;&lt;SPAN&gt;(jkt_tz).&lt;/SPAN&gt;&lt;SPAN&gt;strftime&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'%Y-%m-&lt;/SPAN&gt;&lt;SPAN&gt;%d&lt;/SPAN&gt;&lt;SPAN&gt; %H:%M:%S'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; sysdate&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;spark.udf.&lt;/SPAN&gt;&lt;SPAN&gt;register&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"get_sysdate"&lt;/SPAN&gt;&lt;SPAN&gt;, get_sysdate)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;But sometimes I get the error "_all_timezones_unchecked' is not defined," and the next run works fine.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Sep 2025 08:35:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133153#M49735</guid>
      <dc:creator>AgusBudianto</dc:creator>
      <dc:date>2025-09-28T08:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting NameError name _all_timezones_unchecked' is not defined</title>
      <link>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133197#M49740</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/136509"&gt;@AgusBudianto&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;can you this&lt;/SPAN&gt;&amp;nbsp;and check once? I got it from GPT&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;ensure the pytz library and its timezone data are fully initialized on every worker node before the UDF is called.&lt;/P&gt;&lt;P&gt;import pytz&lt;BR /&gt;from datetime import datetime&lt;/P&gt;&lt;P&gt;# Force pytz to load all timezones on the driver and workers&lt;BR /&gt;# This is a key step to prevent the race condition&lt;BR /&gt;pytz.timezone('UTC')&lt;/P&gt;&lt;P&gt;def get_sysdate():&lt;BR /&gt;jkt_tz = pytz.timezone('Asia/Jakarta')&lt;BR /&gt;sysdate = datetime.now(jkt_tz).strftime('%Y-%m-%d %H:%M:%S')&lt;BR /&gt;return sysdate&lt;/P&gt;&lt;P&gt;spark.udf.register("get_sysdate", get_sysdate)&lt;BR /&gt;&lt;BR /&gt;I did run on my workspace and got these results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Khaja_Zaffer_0-1759104176221.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20277iCA42732A19B29172/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Khaja_Zaffer_0-1759104176221.png" alt="Khaja_Zaffer_0-1759104176221.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 00:03:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133197#M49740</guid>
      <dc:creator>Khaja_Zaffer</dc:creator>
      <dc:date>2025-09-29T00:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting NameError name _all_timezones_unchecked' is not defined</title>
      <link>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133203#M49741</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/173840"&gt;@Khaja_Zaffer&lt;/a&gt;, thank you for being willing to reply to my post I have initiated the function on the 2nd cell, and this problem only appears occasionally, and I am using General Compute&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgusBudianto_2-1759107496030.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20280i819691C9C48CF8E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgusBudianto_2-1759107496030.png" alt="AgusBudianto_2-1759107496030.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;error&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgusBudianto_1-1759107481234.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20279i4C53F3204B7F9F4A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgusBudianto_1-1759107481234.png" alt="AgusBudianto_1-1759107481234.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgusBudianto_3-1759107520702.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20281i2B59EDDE3D1EAC7E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgusBudianto_3-1759107520702.png" alt="AgusBudianto_3-1759107520702.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;in function I have using library:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; datetime &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; datetime, timedelta&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; pytz&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Thank's&lt;/P&gt;&lt;P&gt;Anto&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 01:00:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133203#M49741</guid>
      <dc:creator>AgusBudianto</dc:creator>
      <dc:date>2025-09-29T01:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting NameError name _all_timezones_unchecked' is not defined</title>
      <link>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133232#M49751</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/136509"&gt;@AgusBudianto&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you so much for your response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you try&amp;nbsp;explicitly&amp;nbsp;import inside the UDF, lets see if the error still persisting.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 09:04:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133232#M49751</guid>
      <dc:creator>Khaja_Zaffer</dc:creator>
      <dc:date>2025-09-29T09:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting NameError name _all_timezones_unchecked' is not defined</title>
      <link>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133929#M49964</link>
      <description>&lt;P&gt;Sorry I'm just replying, I think this might be due to the choice of compute specifications but I'm not sure about this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AgusBudianto_0-1759739701328.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/20493i657BE2DCFBE2F300/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AgusBudianto_0-1759739701328.png" alt="AgusBudianto_0-1759739701328.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 08:35:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/133929#M49964</guid>
      <dc:creator>AgusBudianto</dc:creator>
      <dc:date>2025-10-06T08:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting NameError name _all_timezones_unchecked' is not defined</title>
      <link>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/135913#M50462</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/173840"&gt;@Khaja_Zaffer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have connected with MS Support and explained: pytz is no thread safe package, I believe it will have some issue when executor init it parallelly. Second, this is a 3rd&amp;nbsp;party lib, and suggest using the built-in library from&amp;nbsp;&lt;SPAN&gt;ZoneInfo &amp;nbsp;# Python 3.9+&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;def get_sysdate():&lt;BR /&gt;jkt_tz = ZoneInfo("Asia/Jakarta")&lt;BR /&gt;return datetime.now(jkt_tz).strftime('%Y-%m-%d %H:%M:%S')&lt;BR /&gt;&lt;BR /&gt;spark.udf.register("get_sysdate", get_sysdate)&lt;/P&gt;&lt;P class=""&gt;and this worked, the error no longer appeared&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2025 01:54:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/why-am-i-getting-nameerror-name-all-timezones-unchecked-is-not/m-p/135913#M50462</guid>
      <dc:creator>AgusBudianto</dc:creator>
      <dc:date>2025-10-24T01:54:10Z</dc:date>
    </item>
  </channel>
</rss>

