Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble with urllib #598

Open
shivan-s opened this issue Sep 25, 2020 · 2 comments
Open

trouble with urllib #598

shivan-s opened this issue Sep 25, 2020 · 2 comments

Comments

@shivan-s
Copy link

# get the data

import os
import tarfile
import urllib
DOWNLOAD_ROOT = 'https://raw.githubusercontent.com/ageron/handson-ml2/master/'
HOUSING_PATH = os.path.join('datasets', 'housing')
HOUSING_URL = DOWNLOAD_ROOT + 'datasets/housing/housing.tgz'

def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH):
    os.makedirs(housing_path, exist_ok=True)
    tgz_path = os.path.join(housing_path, 'housing.tgz')
    urllib.request.urlretrieve(housing_url, tgz_path)
    housing_tgz = tarfile.open(tgz_path)
    housing_tgz.extractall(path=housing_path)
    housing_tgz.close()

Not really an error with the code in this notebook but in the book. If you use urllib.request method and error will be thrown as it cannot recognise this method.

The workaround I used was import urllib.request. But I see from six.moves import urllib is used instead.

I don't know if anyone found this was a problem or was discussed. Just through my two cents in there and hoping it will help.

@akshitgupta29
Copy link

I am also getting the same error.

@GeoSegun
Copy link

The code in the book is not running properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants