cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

ModuleNotFoundError: No module named 'pyspark.dbutils'

vk217
Contributor

I have a class in a python file like this

 

from pyspark.sql import SparkSession
from pyspark.dbutils import DBUtils
 class DatabricksUtils:

      def __init__(selfโ€Œโ€Œ):
        self.spark = SparkSession.getActiveSession()
        self.dbutils = DBUtils(self.spark)
     
     def get_dbutils(self) -> DBUtils:
        return self.dbutils

 

 

In another python file, I am importing this module and calling the db utils like
 
 from .myProject.functions.utils import *
 
    db = DatabricksUtils()
    dbutils = db.get_dbutils()
 
This works when I test it locally in vscode but in Azure Pipeline when I try to build my unit tests fail and I get a message
ModuleNotFoundError: No module named 'pyspark.dbutils'
 
2 REPLIES 2

Miguel_Suarez
New Contributor III
New Contributor III

Hey @vk217 ,

What Databricks runtime version was the cluster you ran the code on? I was able to successfully run your code in a 12.2 and a 13.3 cluster.

Can you try running it on a cluster with one of those DBR versions, if you haven't already? And please let us know if you're still running into issues.

Best,

Miguel

Poonam_Joshi
New Contributor II

We are trying to do similar thing . we are using dbutils to get secret scope and we doing unittesting in azure pipeline where it gives error pyspark.dbutils not found 

We have tried using databricks.sdk.dbutils for which I got authentication error li kr value not found I used databricks -connect library as well but still the same issue..

Can you please help with it?

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.