ageron / handson-ml

⛔️ DEPRECATED – See https://github.com/ageron/handson-ml3 instead.
Apache License 2.0
25.14k stars 12.91k forks source link

Macports: SSL error on running fetch_housing_data() #617

Closed clenchedteeth closed 3 years ago

clenchedteeth commented 3 years ago

Related to #46, I get an error about SSL certificates. The solutions given in #46 assume that the official python installer was used. However, I am using a macports version of python, and the solutions in #46 do not cover this option. Using macports is one of the approaches that the book recommends, and this piece of code is the first "real" piece of code encountered in the book, so I consider this problem worth addressing in a separate bug report.

Edit: Additionally, the solution e.g. #339 to run pip3 install --upgrade certifi did not work in my case.

jamesonrader commented 3 years ago

Try this, although it might not be super secure if you don't know where you are downloading from:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context
ageron commented 3 years ago

Thanks for your feedback @clenchedteeth. It looks like this page explains what the problem is and how to fix it. Could you please try it? The solution seems to be running:

sudo port install curl-ca-bundle

If this solves the issue, I'll update the README.md to mention this case.

Thanks again!

ps: I personally installed Python using miniconda. There are several benefits, including the fact that you can use different versions of Python depending on the environment, and it does not have any SSL issue. I recommend it.

clenchedteeth commented 3 years ago

@ageron Works perfectly, thank you!