<?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 %run notebook fails in Job mode with Py4JJavaError (None.get), but works in interactive notebook in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/run-notebook-fails-in-job-mode-with-py4jjavaerror-none-get-but/m-p/136340#M50544</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I’m facing an issue when executing a Databricks job where my notebook uses &lt;STRONG&gt;%run to include other notebooks&lt;/STRONG&gt;. I have a final notebook added as a task in a job, and inside that notebook I use &lt;STRONG&gt;%run to call another notebook&lt;/STRONG&gt; that contains all my functions. That second notebook again calls another notebook using %run.&lt;/P&gt;&lt;P&gt;When I run the notebook &lt;STRONG&gt;manually in the UI&lt;/STRONG&gt;, everything works &lt;STRONG&gt;perfectly&lt;/STRONG&gt;. But when the same notebook runs &lt;STRONG&gt;as a job&lt;/STRONG&gt;, it fails with a Py4JJavaError showing &lt;STRONG&gt;“java.util.NoSuchElementException: None.get”&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;There are &lt;STRONG&gt;no missing widgets or paths&lt;/STRONG&gt; because the exact same setup runs fine interactively.&lt;/P&gt;&lt;P&gt;Has anyone else seen this behavior where %run works fine manually but fails with this error in a job? Any &lt;STRONG&gt;suggestions or best practices&lt;/STRONG&gt; would be really helpful.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 28 Oct 2025 07:54:29 GMT</pubDate>
    <dc:creator>Akshay_Petkar</dc:creator>
    <dc:date>2025-10-28T07:54:29Z</dc:date>
    <item>
      <title>%run notebook fails in Job mode with Py4JJavaError (None.get), but works in interactive notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/run-notebook-fails-in-job-mode-with-py4jjavaerror-none-get-but/m-p/136340#M50544</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I’m facing an issue when executing a Databricks job where my notebook uses &lt;STRONG&gt;%run to include other notebooks&lt;/STRONG&gt;. I have a final notebook added as a task in a job, and inside that notebook I use &lt;STRONG&gt;%run to call another notebook&lt;/STRONG&gt; that contains all my functions. That second notebook again calls another notebook using %run.&lt;/P&gt;&lt;P&gt;When I run the notebook &lt;STRONG&gt;manually in the UI&lt;/STRONG&gt;, everything works &lt;STRONG&gt;perfectly&lt;/STRONG&gt;. But when the same notebook runs &lt;STRONG&gt;as a job&lt;/STRONG&gt;, it fails with a Py4JJavaError showing &lt;STRONG&gt;“java.util.NoSuchElementException: None.get”&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;There are &lt;STRONG&gt;no missing widgets or paths&lt;/STRONG&gt; because the exact same setup runs fine interactively.&lt;/P&gt;&lt;P&gt;Has anyone else seen this behavior where %run works fine manually but fails with this error in a job? Any &lt;STRONG&gt;suggestions or best practices&lt;/STRONG&gt; would be really helpful.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2025 07:54:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/run-notebook-fails-in-job-mode-with-py4jjavaerror-none-get-but/m-p/136340#M50544</guid>
      <dc:creator>Akshay_Petkar</dc:creator>
      <dc:date>2025-10-28T07:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: %run notebook fails in Job mode with Py4JJavaError (None.get), but works in interactive notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/run-notebook-fails-in-job-mode-with-py4jjavaerror-none-get-but/m-p/136560#M50591</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/88335"&gt;@Akshay_Petkar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;ARTICLE class="text-token-text-primary w-full focus:outline-none [--shadow-height:45px] has-data-writing-block:pointer-events-none has-data-writing-block:-mt-(--shadow-height) has-data-writing-block:pt-(--shadow-height) [&amp;amp;:has([data-writing-block])&amp;gt;*]:pointer-events-auto [content-visibility:auto] supports-[content-visibility:auto]:[contain-intrinsic-size:auto_100lvh] scroll-mt-[calc(var(--header-height)+min(200px,max(70px,20svh)))]" dir="auto" tabindex="-1" data-turn-id="request-WEB:1ab57063-303a-4f5e-bccf-d42f41c4450a-9" data-testid="conversation-turn-6" data-scroll-anchor="true" data-turn="assistant"&gt;
&lt;DIV class="text-base my-auto mx-auto pb-10 [--thread-content-margin:--spacing(4)] thread-sm:[--thread-content-margin:--spacing(6)] thread-lg:[--thread-content-margin:--spacing(16)] px-(--thread-content-margin)"&gt;
&lt;DIV class="[--thread-content-max-width:40rem] thread-lg:[--thread-content-max-width:48rem] mx-auto max-w-(--thread-content-max-width) flex-1 group/turn-messages focus-visible:outline-hidden relative flex w-full min-w-0 flex-col agent-turn" tabindex="-1"&gt;
&lt;DIV class="flex max-w-full flex-col grow"&gt;
&lt;DIV class="min-h-8 text-message relative flex w-full flex-col items-end gap-2 text-start break-words whitespace-normal [.text-message+&amp;amp;]:mt-1" dir="auto" data-message-author-role="assistant" data-message-id="97a213f0-29a4-4d68-a7c0-db539c32acdc" data-message-model-slug="gpt-5-thinking"&gt;
&lt;DIV class="flex w-full flex-col gap-1 empty:hidden first:pt-[1px]"&gt;
&lt;DIV class="markdown prose dark:prose-invert w-full break-words dark markdown-new-styling"&gt;
&lt;UL data-start="27" data-end="839"&gt;
&lt;LI data-start="27" data-end="176"&gt;
&lt;P data-start="29" data-end="176"&gt;&lt;CODE data-start="29" data-end="35"&gt;%run&lt;/CODE&gt; can break in Jobs due to path resolution—use &lt;STRONG data-start="85" data-end="108" data-is-only-node=""&gt;relative paths&lt;/STRONG&gt; (e.g., &lt;CODE data-start="116" data-end="134"&gt;%run ./lib/utils&lt;/CODE&gt;) and keep all targets in the same Repo.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="177" data-end="375"&gt;
&lt;P data-start="179" data-end="375"&gt;Don’t rely on widget state. Define widgets only in the entry notebook and pass values explicitly (or switch to &lt;CODE data-start="298" data-end="322"&gt;dbutils.notebook.run()&lt;/CODE&gt; with &lt;CODE data-start="328" data-end="345"&gt;arguments={...}&lt;/CODE&gt; for clean, isolated calls).&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="376" data-end="483"&gt;
&lt;P data-start="378" data-end="483"&gt;Avoid nested/chained&lt;STRONG data-start="384" data-end="409"&gt;&lt;CODE data-start="401" data-end="407"&gt;%run&lt;/CODE&gt;&lt;/STRONG&gt; and side-effect cells; &lt;CODE data-start="433" data-end="439"&gt;%run&lt;/CODE&gt; literally inlines code and order matters.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-start="739" data-end="839"&gt;
&lt;P data-start="741" data-end="839"&gt;The recommended approach for a long term mitgatiation is to move shared code into a &lt;STRONG data-start="781" data-end="792"&gt;package&lt;/STRONG&gt; in the Repo and &lt;CODE data-start="809" data-end="817"&gt;import&lt;/CODE&gt; it instead of &lt;CODE data-start="832" data-end="838"&gt;%run&lt;/CODE&gt;.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="z-0 flex min-h-[46px] justify-start"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="mt-3 w-full empty:hidden"&gt;
&lt;DIV class="text-center"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/ARTICLE&gt;</description>
      <pubDate>Wed, 29 Oct 2025 14:56:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/run-notebook-fails-in-job-mode-with-py4jjavaerror-none-get-but/m-p/136560#M50591</guid>
      <dc:creator>K_Anudeep</dc:creator>
      <dc:date>2025-10-29T14:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: %run notebook fails in Job mode with Py4JJavaError (None.get), but works in interactive notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/run-notebook-fails-in-job-mode-with-py4jjavaerror-none-get-but/m-p/136615#M50601</link>
      <description>&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;This issue with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in Databricks notebooks—where everything works interactively in the UI, but fails in a job context with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;java.util.NoSuchElementException: None.get&lt;/CODE&gt;—is a relatively common pain point for users leveraging notebook modularization. The error typically signals a problem with job execution context, notebook state initialization, or workspace scoping, rather than classic code or path issues.&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Why This Happens&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Context Differences&lt;/STRONG&gt;: When running manually, notebook execution is stateful and allows nested&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;calls to inherit context (e.g., widgets, environment variables). Job runs, however, are stateless and reinitialize context per task, not reliably propagating state across nested&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;invocations.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Nested&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Limitations&lt;/STRONG&gt;: Deeply nested&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statements, especially across multiple notebooks, can result in unpredictable behavior, as only top-level&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;receives the initial widget/context setup. Lower-level notebooks may expect context or imports that aren't actually available in job execution.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Widget/Parameter Initialization&lt;/STRONG&gt;: While you report no missing widgets, jobs sometimes fail to initialize notebook widgets as they would in interactive mode, meaning that a called notebook may attempt to access a widget that’s not set.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Best Practices &amp;amp; Workarounds&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Avoid Deep Nesting of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;&lt;/STRONG&gt;: Flatten your notebook structure as much as possible; ideally, have only the main notebook call all dependency notebooks directly (not via chains of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;).&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Use Python Modules for Shared Code&lt;/STRONG&gt;: Instead of chaining functional notebooks with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;%run&lt;/CODE&gt;, convert common functionality into Python modules or scripts, and use standard&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;import&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statements. This pattern is more robust and compatible with both interactive and job contexts.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Check and Initialize Widgets Explicitly&lt;/STRONG&gt;: In job contexts, always set widgets explicitly (using&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;dbutils.widgets&lt;/CODE&gt;) rather than relying on inheritance or implicit initialization from interactive runs.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Preview Job Cluster Configuration&lt;/STRONG&gt;: Ensure that paths and notebook references are correct, and are accessible to the cluster executing the job (sometimes workspace paths work interactively, but fail in jobs due to cluster scope differences).&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Troubleshooting Steps&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Reproduce the issue with reduced nesting—run the second notebook as a direct job task.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Add explicit widget initialization checks and verbose logging in the included notebooks.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Refactor shared code into reusable Python files stored in DBFS or workspace repo, then import in the main notebook.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 29 Oct 2025 19:55:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/run-notebook-fails-in-job-mode-with-py4jjavaerror-none-get-but/m-p/136615#M50601</guid>
      <dc:creator>mark_ott</dc:creator>
      <dc:date>2025-10-29T19:55:53Z</dc:date>
    </item>
  </channel>
</rss>

