ageron / ageron/handson-ml

trouble with urllib

Offen
#598 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Jupyter Notebook
Sterne
25.6k
Forks
12.7k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

```python
# 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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.