<?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: Inconsistent PYTHONPATH, Git folders vs DAB in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/inconsistent-pythonpath-git-folders-vs-dab/m-p/142713#M52012</link>
    <description>&lt;P&gt;I have a related question.&lt;/P&gt;&lt;P&gt;I'm new to Databricks platform. I struggle with PYTHONPATH issue as the original poster raised. I understand using sys.path.append(...) is one approach for notebook. This is acceptable for ad-hoc interactive session, but this doesn't feel right for python module. Suppose I have multiple python modules that need to import a custom module, like the hello.py in the OP's example. I must have sys.path.append(...) line in every module before I import hello.py?&lt;/P&gt;&lt;P&gt;To give an example, let's say I have an utility python module that's a base of other custom modules. Then I have to remember to do sys.path.append(...) before every import. Worse part is if I forget sys.path.append(...), import works in local dev(because most IDE provides a way to set PYTHONPATH to project root) but import fails only after I deploy bundle later.&lt;/P&gt;&lt;P&gt;I feel there must be a way to ensure consistent behavior programmatically without explicit path setting.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Dec 2025 19:12:14 GMT</pubDate>
    <dc:creator>kenny_hero</dc:creator>
    <dc:date>2025-12-30T19:12:14Z</dc:date>
    <item>
      <title>Inconsistent PYTHONPATH, Git folders vs DAB</title>
      <link>https://community.databricks.com/t5/data-engineering/inconsistent-pythonpath-git-folders-vs-dab/m-p/113421#M44528</link>
      <description>&lt;P&gt;Hello Databricks Community,&lt;/P&gt;&lt;P&gt;I'm encountering an issue related to Python paths when working with notebooks in Databricks. I have a following structure in my project:&lt;/P&gt;&lt;LI-CODE lang="css"&gt;my_notebooks
  - my_notebook.py
/my_package
  - __init__.py
  - hello.py
databricks.yml&lt;/LI-CODE&gt;&lt;P&gt;my_notebook.py&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Databricks notebook source
import sys
print(*sys.path, sep='\n')

# COMMAND ----------

from my_package.hello import hello_world
hello_world()&lt;/LI-CODE&gt;&lt;P&gt;hello.py:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def hello_world():
    print('Hello World')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;databricks.yml&lt;/P&gt;&lt;LI-CODE lang="python"&gt;bundle:
  name: my_bundle
targets:
  dev:
    mode: production
    workspace:
      host: https://adb-XXXXXXXXXXXXXXXXXXXXX.azuredatabricks.net
      root_path: /dev/${bundle.name}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I would like to work with the notebooks in two ways:&lt;BR /&gt;- I want all developers to work in their own Git folders&lt;BR /&gt;- then, once their work is done, and a pull request is completed, a pipeline would call `databricks bundle deploy` command to deploy the code to the `dev` environment.&lt;/P&gt;&lt;P&gt;The problem is that when you execute a notebook from someone's Git folder it works fine because Python easily finds the `my_package` package. When you try to execute `my_notebook` from the location it is deployed to by DAB (`/Workspace/dev/my_bundle/files/my_notebooks/my_notebook`), it does not work because `my_package` cannot be imported.&lt;/P&gt;&lt;P&gt;What is the reason for this inconsistency?&lt;BR /&gt;I would like to be able to import python packages from the root of my project, and the fact that the python path behaviour is different in git folders and DAB.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 14:28:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/inconsistent-pythonpath-git-folders-vs-dab/m-p/113421#M44528</guid>
      <dc:creator>mydefaultlogin</dc:creator>
      <dc:date>2025-03-24T14:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent PYTHONPATH, Git folders vs DAB</title>
      <link>https://community.databricks.com/t5/data-engineering/inconsistent-pythonpath-git-folders-vs-dab/m-p/113452#M44537</link>
      <description>&lt;P&gt;Hi&amp;nbsp;mydefaultlogin,&lt;/P&gt;&lt;P&gt;How are you doing today?, As per my understanding,&amp;nbsp;You're right—this happens because when you're running notebooks from your Git folder, Python knows exactly where your project root is and can easily find my_package. But when you deploy using Databricks Asset Bundles (DAB), the notebook runs from a different path (like /Workspace/dev/...), and Python no longer sees your project root by default, so it can't find the package. A simple fix is to manually add your project root to Python's path at the top of your notebook using sys.path.append('/Workspace/dev/my_bundle/files'). This helps Python locate your package just like it does in the Git setup. It’s a common issue with DAB deployments, and this quick adjustment should solve it. Let me know if you’d like help making it reusable!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Brahma&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 20:31:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/inconsistent-pythonpath-git-folders-vs-dab/m-p/113452#M44537</guid>
      <dc:creator>Brahmareddy</dc:creator>
      <dc:date>2025-03-24T20:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent PYTHONPATH, Git folders vs DAB</title>
      <link>https://community.databricks.com/t5/data-engineering/inconsistent-pythonpath-git-folders-vs-dab/m-p/142713#M52012</link>
      <description>&lt;P&gt;I have a related question.&lt;/P&gt;&lt;P&gt;I'm new to Databricks platform. I struggle with PYTHONPATH issue as the original poster raised. I understand using sys.path.append(...) is one approach for notebook. This is acceptable for ad-hoc interactive session, but this doesn't feel right for python module. Suppose I have multiple python modules that need to import a custom module, like the hello.py in the OP's example. I must have sys.path.append(...) line in every module before I import hello.py?&lt;/P&gt;&lt;P&gt;To give an example, let's say I have an utility python module that's a base of other custom modules. Then I have to remember to do sys.path.append(...) before every import. Worse part is if I forget sys.path.append(...), import works in local dev(because most IDE provides a way to set PYTHONPATH to project root) but import fails only after I deploy bundle later.&lt;/P&gt;&lt;P&gt;I feel there must be a way to ensure consistent behavior programmatically without explicit path setting.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2025 19:12:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/inconsistent-pythonpath-git-folders-vs-dab/m-p/142713#M52012</guid>
      <dc:creator>kenny_hero</dc:creator>
      <dc:date>2025-12-30T19:12:14Z</dc:date>
    </item>
  </channel>
</rss>

