Nasgar
Nasgar

Reputation: 951

New databricks feature: import is not working

I have uploaded my databricks notebooks to a repo and replace %run sentences with import using the new databrick public available features (Repo integration and python import): https://databricks.com/blog/2021/10/07/databricks-repos-is-now-generally-available.html

But its seems its not working

I already activate the repo integration option in the Admin panel but i Get this error

ModuleNotFoundError: No module named 'petitions'

For simplicity I moved all python files to the same directory. I get the error in the procesado notebook

[Repo structure1

Upvotes: 1

Views: 7620

Answers (2)

user3342784
user3342784

Reputation: 103

If your are using Azure DataBricks and Python Notebooks, you can't import them as modules.

From the documentation:

If you want to import the notebook as a Python module, you must edit the notebook in a code editor and remove the line # Databricks Notebook source. Removing that line converts the notebook to a regular Python file.

Documentation: https://learn.microsoft.com/en-us/azure/databricks/repos#work-with-python-and-r-modules

Upvotes: 0

Hubert Dudek
Hubert Dudek

Reputation: 1730

Please try to use full path to file from repo root:

from folders.file import class

Upvotes: 0

Related Questions