Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import own modules from repo on Databricks?

I have connected a Github repository to my Databricks workspace, and am trying to import a module that's in this repo into a notebook also within the repo. The structure is as such:

Repo_Name

  • Checks.py
  • Test.ipynb

The path to this repo is in my sys.path(), yet I still get ModuleNotFoundError: No module named 'Checks'. When I try to do import Checks. This link explains that you should be able to import any modules that are in the PATH. Does anyone know why it might still not be working?

like image 926
MKJ Avatar asked Oct 18 '25 13:10

MKJ


1 Answers

Most probably your .py file is a notebook, not a Python file. Notebooks couldn't be imported as Python modules, only Python files could be used in this case.

You can check if this .py has the following text in the first line:

# Databricks notebook source

If it contains, you can remove this line, and file will be considered as Python file, not as a notebook.

like image 123
Alex Ott Avatar answered Oct 20 '25 03:10

Alex Ott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!