Unable to define path in Chapter 5 JupyterNotebook

Hello there,
So i just received an error message from the third code block from the Chapter 5 in Jupyter, the code up to where i am is just:

!pip install -Uqq fastbook
import fastbook

from fastbook import *

from fastai.vision.all import *
path = untar_data(URLs.PETS)

And i get this error traceback:


FileExistsError Traceback (most recent call last)
1 from fastai.vision.all import *
----> 2 path = untar_data(URLs.PETS)

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/data/external.py in untar_data(url, fname, dest, c_key, force_download, extract_func, timeout)
257 if _get_check(url) and _check_file(fname) != _get_check(url):
258 print(f"File downloaded is broken. Remove {fname} and try again.")
–> 259 extract_func(fname, dest.parent)
260 rename_extracted(dest)
261 return dest

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/data/external.py in file_extract(fname, dest)
217 if dest is None: dest = Path(fname).parent
218 fname = str(fname)
–> 219 if fname.endswith(‘gz’): tarfile.open(fname, ‘r:gz’).extractall(dest)
220 elif fname.endswith(‘zip’): zipfile.ZipFile(fname ).extractall(dest)
221 else: raise Exception(f’Unrecognized archive: {fname}’)

/opt/conda/envs/fastai/lib/python3.8/tarfile.py in extractall(self, path, members, numeric_owner)
2024 tarinfo.mode = 0o700
2025 # Do not set_attrs directories, as we will do that further down
-> 2026 self.extract(tarinfo, path, set_attrs=not tarinfo.isdir(),
2027 numeric_owner=numeric_owner)

/opt/conda/envs/fastai/lib/python3.8/tarfile.py in extract(self, member, path, set_attrs, numeric_owner)
2066 try:
-> 2067 self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
2068 set_attrs=set_attrs,
2069 numeric_owner=numeric_owner)

/opt/conda/envs/fastai/lib/python3.8/tarfile.py in _extract_member(self, tarinfo, targetpath, set_attrs, numeric_owner)
2129 # Create directories that are not part of the archive with
2130 # default permissions.
-> 2131 os.makedirs(upperdirs)
2133 if tarinfo.islnk() or tarinfo.issym():

/opt/conda/envs/fastai/lib/python3.8/os.py in makedirs(name, mode, exist_ok)
221 return
222 try:
–> 223 mkdir(name, mode)
224 except OSError:
225 # Cannot rely on checking for EEXIST, since the operating system

FileExistsError: [Errno 17] File exists: ‘/storage/data/oxford-iiit-pet’

I tried to wrap my head around what’s written, but i could not. Could anyone help me with this?

Hi! I think it has to do with the folder already being present in your download-to path. If you’re using Linux you should be able to do rm -rf /storage/data/oxford-iiit-pet or on Windows you should be able to navigate to this path and remove it. Maybe try again after doing this?

1 Like

Oh, thank you very much! Little to no experience in linux and the Paperspace got me confused.
It works now

1 Like