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:
Jerome Lovy
2021-01-25 11:55:32 +01:00
parent 8ebdcffc6b
commit 9b7ab19c56
5 changed files with 5 additions and 5 deletions

View File

@@ -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",