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

AttributeError: module 'pyspark.dbutils' has no attribute 'fs'

kll
New Contributor III

`AttributeError` when attempting to transfer files from `dbfs` filestore in DataBricks to a local directory. 

 import pyspark.dbutils as pdbutils
 
  pdbutils.fs.cp("/dbfs/Data/file1.csv", "/Users/Downloads/")
 
  Traceback (most recent call last):
 
   File "/databricks/python/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3378, in run_code
 
    exec(code_obj, self.user_global_ns, self.user_ns)
 
   File "<command-1495140876495465>", line 4, in <module>
 
    pdbutils.fs.cp("/dbfs/Usage-Data/df_tx_0106_2022.csv", "/Users/keval/Downloads/")
 
  AttributeError: module 'pyspark.dbutils' has no attribute 'fs'

2 REPLIES 2

NandiniN
Valued Contributor II
Valued Contributor II

Hello @Keval Shah​ .

The import of dbutils is not explicitly required. (https://docs.databricks.com/dev-tools/databricks-utils.html#file-system-utility-dbutilsfs)

You can use the steps below to copy the file (https://docs.databricks.com/dev-tools/databricks-utils.html#file-system-utility-dbutilsfs)

dbutils.fs.cp("/FileStore/old_file.txt", "/tmp/new/new_file.txt") to copy the file.

I just listed dbutils.fs.ls("/mnt") and it works fine for a python notebook.

Hope this helps.

Thanks & Regards,

Nandini

Anonymous
Not applicable

Hi @Keval Shah​ 

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance! 

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.