Open mzeman1 opened 4 years ago
Same issue here, running on my Jetson nano. When I run this code i get a urllib request error. Importing urlib.request fixed that; however, even after calling the function I don't get a directory made and am currently investigating the path as that doesn't work either.
did you call the function? (which is in the next cell) fetch_housing_data()
fetch_housing_data() called... Error output HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 404: Not Found
from __future__ import division, print_function, unicode_literals
import numpy as np
import os
import pandas as pd
import tarfile
from six.moves import urllib
DOWNLOAD_ROOT = "https://raw.githubusercontent.com/ageron/handson-ml/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):
if not os.path.isdir(housing_path):
os.makedirs(housing_path)
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()
I didn't. But now, it gave me this error:
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>
Hello community, just started with this interesting book, but a problem came over with this following code:
%matplotlib inline import matplotlib.pyplot as plt housing.hist(bins=50, figsize=(20,15)) save_fig("attribute_histogram_plots") plt.show()
Once I deployed, it shows the following error:
AttributeError Traceback (most recent call last)
I had the same error
Hi there,
@mzeman1 , you're running into a very common problem which is linked to the installation of Python on MacOSX. You need to install the SSL certificates. I explain how in the FAQ.
@Cpauls35 , getting an HTTP 404 error is weird. This means that the URL is invalid. The only explanation I can see is there's a typo in your code. Please make sure you're running exactly the same code as in the notebook. If it still doesn't work, please check your network settings, perhaps a firewall or proxy is messing things up. In any case, if you run the notebook in Colab, you will see that everything works fine.
@2807754 and @zkDreamer , this StackOverflow question seems to have an accepted answer that may fix your problem: in short, uninstall matplotlib and reinstall it.
Hope this helps.
@mzeman1, I just had this same error (On macOS Monterey 12.2.1 (21D62) on an M1 MacBook Air), and the following Github answer solved the problem for me.
https://github.com/Cadene/pretrained-models.pytorch/issues/193#issuecomment-635730515
I reworked the data fetching logic for Chapter 2 into the following, which worked on my machine:
def fetch_data(url, path, archive_name):
# Workaround for https://github.com/Cadene/pretrained-models.pytorch/issues/193#issuecomment-635730515
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
os.makedirs(path, exist_ok=True)
archive_path = os.path.join(path, archive_name)
urllib.request.urlretrieve(url, archive_path)
archive = tarfile.open(archive_path)
archive.extractall(path)
archive.close()
@AlejandorLazaro , please don't do this ! It deactivates all SSL verification, basically destroying all SSL security. It's not the right solution. Instead, please install the root certificates by opening a terminal and running the following command (change 3.10 to whatever Python version you are using):
/Applications/Python\ 3.10/Install\ Certificates.command
This will install the certifi
bundle of root certificates and solve the problem without destroying all security.
If you installed Python using MacPorts, then run sudo port install curl-ca-bundle
instead.
Whoops! Thanks for the response and correction there!
This code doesn't work for me: