06_multicat: error with untar_data(URLs.PASCAL_2007)

I just started the 06_multicat codebook and when I ran the following code

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

I got this error

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
/opt/conda/lib/python3.7/shutil.py in move(src, dst, copy_function)
    565     try:
--> 566         os.rename(src, real_dst)
    567     except OSError:

OSError: [Errno 18] Invalid cross-device link: '/tmp/tmpkbvr78q6/pascal_2007/pascal_2007' -> '/storage/data/pascal_2007'

During handling of the above exception, another exception occurred:

FileExistsError                           Traceback (most recent call last)
/tmp/ipykernel_98/3287698347.py in <module>
      1 from fastai.vision.all import *
----> 2 path = untar_data(URLs.PASCAL_2007)

/opt/conda/lib/python3.7/site-packages/fastai/data/external.py in untar_data(url, archive, data, c_key, force_download)
    122     "Download `url` to `fname` if `dest` doesn't exist, and extract to folder `dest`"
    123     d = FastDownload(fastai_cfg(), module=fastai.data, archive=archive, data=data, base='~/.fastai')
--> 124     return d.get(url, force=force_download, extract_key=c_key)

/opt/conda/lib/python3.7/site-packages/fastdownload/core.py in get(self, url, extract_key, force)
    120             if data.exists(): return data
    121         self.download(url, force=force)
--> 122         return self.extract(url, extract_key=extract_key, force=force)

/opt/conda/lib/python3.7/site-packages/fastdownload/core.py in extract(self, url, extract_key, force)
    112         dest = self.data_path(extract_key)
    113         dest.mkdir(exist_ok=True, parents=True)
--> 114         return untar_dir(arch, dest, rename=True, overwrite=force)
    115 
    116     def get(self, url, extract_key='data', force=False):

/opt/conda/lib/python3.7/site-packages/fastcore/xtras.py in untar_dir(fname, dest, rename, overwrite)
    231             else: return dest
    232         if rename: src = _unpack(fname, out)
--> 233         shutil.move(str(src), dest)
    234         return dest
    235 

/opt/conda/lib/python3.7/shutil.py in move(src, dst, copy_function)
    575                             " '%s'." % (src, dst))
    576             copytree(src, real_dst, copy_function=copy_function,
--> 577                      symlinks=True)
    578             rmtree(src)
    579         else:

/opt/conda/lib/python3.7/shutil.py in copytree(src, dst, symlinks, ignore, copy_function, ignore_dangling_symlinks)
    322         ignored_names = set()
    323 
--> 324     os.makedirs(dst)
    325     errors = []
    326     for name in names:

/opt/conda/lib/python3.7/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/pascal_2007'

I tried to use the same trick I did for the previous code book (i.e., rm -rf /storage/data/oxford-iiit-pet)

with this code

 rm -rf /storage/data/pascal_2007

but got this error which i didn’t get on the previous codebook

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/tmp/ipykernel_98/4088854241.py in <module>
      1 #removes old data from previous runs
----> 2 rm -rf /storage/data/pascal_2007

NameError: name 'rm' is not defined

any guidance on how to solve???

if you execute that from notebook, use this ! in front:

!rm -rf /storage/data/pascal_2007
1 Like

That worked! Thank you!!!

1 Like