0

I am new to Python and coding and was trying to learn web scraping. I am getting the certificate verification error. I have read other posts suggesting setting (verify = False) but others discouraged this for safety reasons.

I tried to install pip3 install certifi and I get (Requirement already satisfied:)

Code line:

urllib.request.urlopen("https://automatetheboringstuff.com").read()

Error: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>

I tried other websites, like google and yahoo which appear safe and Safari is accepting its certificate, but when I try with Python I get the same error.

Is there a safe solution to this?

Shankar Ganesh Jayaraman
  • 1,401
  • 1
  • 16
  • 22
MTJ
  • 1
  • On which OS are you ? Have you checked [this](https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error) or [this](https://stackoverflow.com/questions/49183801/ssl-certificate-verify-failed-with-urllib)? – emmunaf Dec 16 '20 at 14:24
  • I have Catalina. I look at both posts. The first one discouraged setting the ssl to unverified context = ssl._create_unverified_context() Someone else suggested adding/updating certificates. > pip install certifi > Requirement already satisfied: certifi in ./venv/lib/python3.6/site-packages (2020.12.5) – MTJ Dec 17 '20 at 18:57
  • Also tried: > /Applications/Python\ 3.6/Install\ Certificates.command PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/certifi' You are using pip version 9.0.3, however version 20.3.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command. – MTJ Dec 17 '20 at 19:00
  • It finally worked. There is a file named (install certificate.command) within Python folder in applications. I had to run that file. – MTJ Dec 17 '20 at 22:35
  • I'm happy for you, it was one of the most upvoted answer in the (first) so question I linked. As a suggestion for the next time, try to search about your problem as first! – emmunaf Dec 18 '20 at 07:25

0 Answers0