fastai / fastbook

The fastai book, published as Jupyter Notebooks
Other
21.51k stars 8.33k forks source link

Running untar_data(URLs.PETS)/'images' fails #576

Open r-wells opened 1 year ago

r-wells commented 1 year ago

Trying to load the images from this url with untar_data and getting the following exception:

gaierror                                  Traceback (most recent call last)
/opt/conda/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1349                 h.request(req.get_method(), req.selector, req.data, headers,
-> 1350                           encode_chunked=req.has_header('Transfer-encoding'))
   1351             except OSError as err: # timeout error

/opt/conda/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1280         """Send a complete request to the server."""
-> 1281         self._send_request(method, url, body, headers, encode_chunked)
   1282 

/opt/conda/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1326             body = _encode(body, 'body')
-> 1327         self.endheaders(body, encode_chunked=encode_chunked)
   1328 

/opt/conda/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked)
   1275             raise CannotSendHeader()
-> 1276         self._send_output(message_body, encode_chunked=encode_chunked)
   1277 

/opt/conda/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked)
   1035         del self._buffer[:]
-> 1036         self.send(msg)
   1037 

/opt/conda/lib/python3.7/http/client.py in send(self, data)
    975             if self.auto_open:
--> 976                 self.connect()
    977             else:

/opt/conda/lib/python3.7/http/client.py in connect(self)
   1442 
-> 1443             super().connect()
   1444 

/opt/conda/lib/python3.7/http/client.py in connect(self)
    947         self.sock = self._create_connection(
--> 948             (self.host,self.port), self.timeout, self.source_address)
    949         self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

/opt/conda/lib/python3.7/socket.py in create_connection(address, timeout, source_address)
    706     err = None
--> 707     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    708         af, socktype, proto, canonname, sa = res

/opt/conda/lib/python3.7/socket.py in getaddrinfo(host, port, family, type, proto, flags)
    751     addrlist = []
--> 752     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    753         af, socktype, proto, canonname, sa = res

gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
/tmp/ipykernel_27/4049553439.py in <module>
      1 from fastai.vision.all import *
----> 2 path = untar_data(URLs.PETS)/'images'

/opt/conda/lib/python3.7/site-packages/fastai/data/external.py in untar_data(url, archive, data, c_key, force_download, base)
    134     "Download `url` using `FastDownload.get`"
    135     d = FastDownload(fastai_cfg(), module=fastai.data, archive=archive, data=data, base=base)
--> 136     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)
    115             data = self.data_path(extract_key, urldest(url, self.arch_path()))
    116             if data.exists(): return data
--> 117         self.download(url, force=force)
    118         return self.extract(url, extract_key=extract_key, force=force)

/opt/conda/lib/python3.7/site-packages/fastdownload/core.py in download(self, url, force)
     90         "Download `url` to archive path, unless exists and `self.check` fails and not `force`"
     91         self.arch_path().mkdir(exist_ok=True, parents=True)
---> 92         return download_and_check(url, urldest(url, self.arch_path()), self.module, force)
     93 
     94     def rm(self, url, rm_arch=True, rm_data=True, extract_key='data'):

/opt/conda/lib/python3.7/site-packages/fastdownload/core.py in download_and_check(url, fpath, fmod, force)
     59         if check(fmod, url, fpath): return fpath
     60         else: print("Downloading a new version of this dataset...")
---> 61     res = download_url(url, fpath)
     62     if not check(fmod, url, fpath): raise Exception("Downloaded file is corrupt or not latest version")
     63     return res

/opt/conda/lib/python3.7/site-packages/fastdownload/core.py in download_url(url, dest, timeout, show_progress)
     17         pbar.total = tsize
     18         pbar.update(count*bsize)
---> 19     return urlsave(url, dest, reporthook=progress if show_progress else None, timeout=timeout)
     20 
     21 # Cell

/opt/conda/lib/python3.7/site-packages/fastcore/net.py in urlsave(url, dest, reporthook, headers, timeout)
    182     dest = urldest(url, dest)
    183     dest.parent.mkdir(parents=True, exist_ok=True)
--> 184     nm,msg = urlretrieve(url, dest, reporthook, headers=headers, timeout=timeout)
    185     return nm
    186 

/opt/conda/lib/python3.7/site-packages/fastcore/net.py in urlretrieve(url, filename, reporthook, data, headers, timeout)
    147 def urlretrieve(url, filename=None, reporthook=None, data=None, headers=None, timeout=None):
    148     "Same as `urllib.request.urlretrieve` but also works with `Request` objects"
--> 149     with contextlib.closing(urlopen(url, data, headers=headers, timeout=timeout)) as fp:
    150         headers = fp.info()
    151         if filename: tfp = open(filename, 'wb')

/opt/conda/lib/python3.7/site-packages/fastcore/net.py in urlopen(url, data, headers, timeout, **kwargs)
    106         if not isinstance(data, (str,bytes)): data = urlencode(data)
    107         if not isinstance(data, bytes): data = data.encode('ascii')
--> 108     try: return urlopener().open(urlwrap(url, data=data, headers=headers), timeout=timeout)
    109     except HTTPError as e:
    110         e.msg += f"\n====Error Body====\n{e.read().decode(errors='ignore')}"

/opt/conda/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
    523             req = meth(req)
    524 
--> 525         response = self._open(req, data)
    526 
    527         # post-process response

/opt/conda/lib/python3.7/urllib/request.py in _open(self, req, data)
    541         protocol = req.type
    542         result = self._call_chain(self.handle_open, protocol, protocol +
--> 543                                   '_open', req)
    544         if result:
    545             return result

/opt/conda/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    501         for handler in handlers:
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:
    505                 return result

/opt/conda/lib/python3.7/urllib/request.py in https_open(self, req)
   1391         def https_open(self, req):
   1392             return self.do_open(http.client.HTTPSConnection, req,
-> 1393                 context=self._context, check_hostname=self._check_hostname)
   1394 
   1395         https_request = AbstractHTTPHandler.do_request_

/opt/conda/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1350                           encode_chunked=req.has_header('Transfer-encoding'))
   1351             except OSError as err: # timeout error
-> 1352                 raise URLError(err)
   1353             r = h.getresponse()
   1354         except:

URLError: <urlopen error [Errno -3] Temporary failure in name resolution>

Any ideas what's happening?

jeremAnd commented 1 year ago

Did you ever find a solution? I am having the same problem.