cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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
Databricks Employee
Databricks Employee

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! 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group