โ10-21-2024 12:33 AM
We are able to run a notebook that references Python code using import statements from a Databricks repo
with the source code checked out. However, we encounter a ModuleNotFoundError when executing the same code from a folder.
Error: ModuleNotFoundError: No module named ...
Is there a future roadmap to enable code execution from Databricks folder and subfolders?
โ10-21-2024 12:56 AM
Hi Kartik,
Can you elaborate further on your query? I may not able to understand you properly but if your source code is checked out to databricks repos and you want to execute your code for testing purposes , had you try setting up your repo dir into sys paths?
this can go into the top cell of your execution notebook before you're doing your imports.
โ10-21-2024 12:56 AM
Hi Kartik,
Can you elaborate further on your query? I may not able to understand you properly but if your source code is checked out to databricks repos and you want to execute your code for testing purposes , had you try setting up your repo dir into sys paths?
this can go into the top cell of your execution notebook before you're doing your imports.
โ10-21-2024 03:20 AM
Hi @Kartikb ,
This feature is already available.
As @saurabh18cs mentioned, you probably have not added the location of your python code to sys.path.
Also, it is important to note, that your python code must be a file, and not a notebook. You can recognize by checking the object icon or object type:
โ10-21-2024 04:42 AM
@Kartikb Best approach is by creating a package and Install Code as a Module or Wheel. This ensures your code is accessible across notebooks and distributed jobs without manual path adjustmentsโ
โ10-21-2024 05:21 AM
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโt want to miss the chance to attend and share knowledge.
If there isnโt a group near you, start one and help create a community that brings people together.
Request a New Group