AttributeError: module 'pyspark.dbutils' has no attribute 'fs'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 10:50 AM
`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'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 02:45 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 12:22 AM
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!