mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-14 20:19:29 +01:00
Import urllib.request instead of urllib
As of January 25, 2021, in some environments, such as Colab (Python 3.6.9),
the following import statement
import urllib
is not the right one for using urllib.request.
Indeed, calls to urllib.request functions then yield the following error:
AttributeError: module 'urllib' has no attribute 'request'
One must import urllib.request instead.
See also https://stackoverflow.com/q/22278993
This commit is contained in:
@@ -124,7 +124,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Download the data\n",
|
||||
"import urllib\n",
|
||||
"import urllib.request\n",
|
||||
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
||||
"os.makedirs(datapath, exist_ok=True)\n",
|
||||
"for filename in (\"oecd_bli_2015.csv\", \"gdp_per_capita.csv\"):\n",
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
"source": [
|
||||
"import os\n",
|
||||
"import tarfile\n",
|
||||
"import urllib\n",
|
||||
"import urllib.request\n",
|
||||
"\n",
|
||||
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
||||
"HOUSING_PATH = os.path.join(\"datasets\", \"housing\")\n",
|
||||
|
||||
@@ -1918,7 +1918,7 @@
|
||||
"source": [
|
||||
"import os\n",
|
||||
"import tarfile\n",
|
||||
"import urllib\n",
|
||||
"import urllib.request\n",
|
||||
"\n",
|
||||
"DOWNLOAD_ROOT = \"http://spamassassin.apache.org/old/publiccorpus/\"\n",
|
||||
"HAM_URL = DOWNLOAD_ROOT + \"20030228_easy_ham.tar.bz2\"\n",
|
||||
|
||||
@@ -935,7 +935,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import urllib\n",
|
||||
"import urllib.request\n",
|
||||
"from sklearn.datasets import fetch_openml\n",
|
||||
"\n",
|
||||
"mnist = fetch_openml('mnist_784', version=1)\n",
|
||||
|
||||
@@ -1430,7 +1430,7 @@
|
||||
"source": [
|
||||
"import os\n",
|
||||
"import tarfile\n",
|
||||
"import urllib\n",
|
||||
"import urllib.request\n",
|
||||
"\n",
|
||||
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
||||
"HOUSING_PATH = os.path.join(\"datasets\", \"housing\")\n",
|
||||
|
||||
Reference in New Issue
Block a user