ageron / handson-ml

⛔️ DEPRECATED – See https://github.com/ageron/handson-ml3 instead.
Apache License 2.0
25.2k stars 12.91k forks source link

Chapter 2 HTTP Error 404 #420

Open EmmS21 opened 5 years ago

EmmS21 commented 5 years ago

Getting a traceback when I try and run fetch_housing().

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-19-6ada1818e178> in <module>
----> 1 fetch_housing()

<ipython-input-15-981f9394002a> in fetch_housing(housing_url, housing_path)
      5     tgz_path = os.path.join(housing_path,'housing.tgz')
      6     print(tgz_path)
----> 7     urllib.request.urlretrieve(housing_url,tgz_path)
      8     housing_tgz = tarfile.open(tgz_path)
      9     housing_tgz.extractall(path=housing_path)

~/anaconda3/lib/python3.7/urllib/request.py in urlretrieve(url, filename, reporthook, data)
    245     url_type, path = splittype(url)
    246 
--> 247     with contextlib.closing(urlopen(url, data)) as fp:
    248         headers = fp.info()
    249 

~/anaconda3/lib/python3.7/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

~/anaconda3/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
    529         for processor in self.process_response.get(protocol, []):
    530             meth = getattr(processor, meth_name)
--> 531             response = meth(req, response)
    532 
    533         return response

~/anaconda3/lib/python3.7/urllib/request.py in http_response(self, request, response)
    639         if not (200 <= code < 300):
    640             response = self.parent.error(
--> 641                 'http', request, response, code, msg, hdrs)
    642 
    643         return response

~/anaconda3/lib/python3.7/urllib/request.py in error(self, proto, *args)
    567         if http_err:
    568             args = (dict, 'default', 'http_error_default') + orig_args
--> 569             return self._call_chain(*args)
    570 
    571 # XXX probably also want an abstract factory that knows when it makes

~/anaconda3/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

~/anaconda3/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found

This is what I get when I run housing_url

'https://raw.githubusercontent.com/ageron/hanson-ml/master/datasets/housing/housing.tgz'

ageron commented 5 years ago

Hi @EmmS21 , Thanks for your question. I think you're missing a "d" in "handson-ml", in the URL. Hope this helps.

brianndungunjenga commented 4 years ago

try using this code:

DOWNLOAD_ROOT = "https://github.com/ageron/handson-ml2/blob/master/" HOUSING_PATH = os.path.join("datasets", "housing") ADDITIONAL_PARAM = "?raw=true" HOUSING_URL = DOWNLOAD_ROOT + "datasets/housing/housing.tgz" + ADDITIONAL_PARAM

hope this helps