Referenced Notebook not found

66 views Asked by At

I'm given a notebook to run in Azure Databricks. I imported the notebook to my user folder Workspace\Users\[email protected]. Following command in the notebook gives the error shown below.

Question: Where is the referenced notebook qc_notebook located in Databricks?

My notebook that I am running following command on is at Workspace\Users\[email protected] location in Databricks:

%run ../../qc_functions

Error:

Notebook not found: qc_functions. Notebooks can be specified via a relative path (./Notebook or ../folder/Notebook) or via an absolute path (/Abs/Path/to/Notebook). Make sure you are specifying the path correctly. Stacktrace: /Users/[email protected]/myNotebook: python

1

There are 1 answers

0
JayashankarGS On

%run only supports to run databricks notebooks and not for python script files(.py)

When you import .py file it automatically converts it to notebook type, try checking it if it is still showing as .py then follow below steps to convert it.

enter image description here

Convert the script file as notebook by adding below comments in it.

# Databricks notebook source

Add above comment at the starting of the file, and

# COMMAND ----------

For creating cell.

Below is the code i have added in my .py file and imported it in databricks workspace.

# Databricks notebook source

# COMMAND ----------
print("hi")

If it is converted to notebook type, then run below command.

%run /Users/[email protected]/file_name

Output: enter image description here

Refer this for more information.