mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-30 03:27:54 +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": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Download the data\n",
|
"# Download the data\n",
|
||||||
"import urllib\n",
|
"import urllib.request\n",
|
||||||
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
||||||
"os.makedirs(datapath, exist_ok=True)\n",
|
"os.makedirs(datapath, exist_ok=True)\n",
|
||||||
"for filename in (\"oecd_bli_2015.csv\", \"gdp_per_capita.csv\"):\n",
|
"for filename in (\"oecd_bli_2015.csv\", \"gdp_per_capita.csv\"):\n",
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"import tarfile\n",
|
"import tarfile\n",
|
||||||
"import urllib\n",
|
"import urllib.request\n",
|
||||||
"\n",
|
"\n",
|
||||||
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
||||||
"HOUSING_PATH = os.path.join(\"datasets\", \"housing\")\n",
|
"HOUSING_PATH = os.path.join(\"datasets\", \"housing\")\n",
|
||||||
|
|||||||
@@ -1918,7 +1918,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"import tarfile\n",
|
"import tarfile\n",
|
||||||
"import urllib\n",
|
"import urllib.request\n",
|
||||||
"\n",
|
"\n",
|
||||||
"DOWNLOAD_ROOT = \"http://spamassassin.apache.org/old/publiccorpus/\"\n",
|
"DOWNLOAD_ROOT = \"http://spamassassin.apache.org/old/publiccorpus/\"\n",
|
||||||
"HAM_URL = DOWNLOAD_ROOT + \"20030228_easy_ham.tar.bz2\"\n",
|
"HAM_URL = DOWNLOAD_ROOT + \"20030228_easy_ham.tar.bz2\"\n",
|
||||||
|
|||||||
@@ -935,7 +935,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import urllib\n",
|
"import urllib.request\n",
|
||||||
"from sklearn.datasets import fetch_openml\n",
|
"from sklearn.datasets import fetch_openml\n",
|
||||||
"\n",
|
"\n",
|
||||||
"mnist = fetch_openml('mnist_784', version=1)\n",
|
"mnist = fetch_openml('mnist_784', version=1)\n",
|
||||||
|
|||||||
@@ -1430,7 +1430,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"import tarfile\n",
|
"import tarfile\n",
|
||||||
"import urllib\n",
|
"import urllib.request\n",
|
||||||
"\n",
|
"\n",
|
||||||
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
"DOWNLOAD_ROOT = \"https://raw.githubusercontent.com/ageron/handson-ml2/master/\"\n",
|
||||||
"HOUSING_PATH = os.path.join(\"datasets\", \"housing\")\n",
|
"HOUSING_PATH = os.path.join(\"datasets\", \"housing\")\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user