โ10-27-2021 08:14 AM
I am new to learning Spark and working on some practice; I have uploaded a zip file in DBFS /FileStore/tables directory and trying to run a python code to unzip the file; The python code is as:
from zipfile import *
with ZipFile("/FileStore/tables/flight_data.zip", "r") as zipObj:
zipObj.extractall()
It throws an error:
FileNotFoundError: [Errno 2] No such file or directory: '/FileStore/tables/flight_data.zip'
When i check manually and also through the code dbutils.fs.ls("/FileStore/tables/") it returns
Out[13]: [ FileInfo(path='dbfs:/FileStore/tables/flight_data.zip', name='flight_data.zip', size=59082358)]
Can someone please review and advise; I am using community edition to run this on cluster with configuration:
Data Bricks Runtime Version 8.3 (includes Apache Spark 3.1.1, Scala 2.12)
โ10-27-2021 10:16 AM
It is on dbfs mount so in most scenarios you should prefix everything with /dbfs (or dbfs:/ in databricks native functions, in many is not even needed as they handle only dbfs like dbutils). So please try:
from zipfile import *
with ZipFile("/dbfs/FileStore/tables/flight_data.zip", "r") as zipObj:
zipObj.extractall()
โ10-27-2021 10:29 AM
โ@Hubert Dudekโ
โ
Hello Sir,
I tried in the way you suggested as well.However no luck! Still gives the same error.
โ
Thank you,
Goutamโ
โ10-27-2021 10:40 AM
Do you have maybe high-concurrency server or some limited trial version (trial/free can make problem with reading with not native libraries).
Try also to explorer filesystem using shell commands by putting magic %sh in the first line in notebook to see is there /dbfs folder
%sh
ls /
โ10-27-2021 10:48 AM
@Hubert Dudekโ
Hi Sir,
โ
Working in community edition; Tried with magic commands as well.No luck! It says the command is not recognized.
โ
โ10-28-2021 01:50 AM
so it seems that in community edition you can not direct access filesystem. You have access only to dbfs storage but you need to load there uncompressed object. So you need everywhere to prefix with dbfs:/ if it is not work for some function it will not work. As a last chance you can give a try like that:
from zipfile import *
with ZipFile("dbfs:/FileStore/tables/flight_data.zip", "r") as zipObj:
zipObj.extractall()
โ10-28-2021 03:20 AM
@Hubert Dudekโ
โ
Hi Sir, No luck with this way also. :(.โ
โ
Thank you for all the great suggestions though.๐โ
โ11-18-2021 09:55 AM
Hi @Goutam Palโ ,
Are you still having this issue? I think @Kaniz Fatmaโ example will work great to solve your issue.
โ11-18-2021 07:10 PM
@Jose Gonzalezโ @Kaniz Fatmaโ : The issue still persists. Please find attached the screenshot of the error.
Thanks,
Goutam Pal
โ11-19-2021 08:47 AM
@Goutam Palโ - Thank you for letting us know. I apologize about the inconvenience.
โ12-03-2021 10:51 AM
Hello Kaniz..Will try and revert you back.
โ01-29-2022 11:20 AM
I changed the Databricks runtimeโ version in cluster and it worked in my case. Thank you @Kaniz Fatmaโ
โ07-19-2023 08:36 AM
What if changing the runtime is not an option? I'm experiencing a similar issue using the following:
%pip install -r /dbfs/path/to/file.txt
This worked for a while, but now I'm getting the Errno 2 mentioned above. I am still able to print the same file using dbutils.fs.head('dbfs:/path/to/file.txt')
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