Hello Guys, How are you all? Hope You all Are Fine. Today I am just trying to use BeautifulSoup and I am using urlopen But It gives me following error in my mac certificate verify failed: unable to get local issuer certificate in python. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
How certificate verify failed: unable to get local issuer certificate Error Occurs ?
I am just trying to use BeautifulSoup and I am using urlopen But It gives me following error in my mac.
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1049)>
How To Solve certificate verify failed: unable to get local issuer certificate Error ?
How To Solve certificate verify failed: unable to get local issuer certificate Error ?
To Solve certificate verify failed: unable to get local issuer certificate Error you just need to Install Certificates.command. Just follow this step In macOS just open Macintosh HD Now Select Application Then Select Python folder ( Python3.6, Python3.7 Whatever You are using just select this folder ) Then, double click on Install Certificates.command. Now your error should be solved.
certificate verify failed: unable to get local issuer certificate
To Solve certificate verify failed: unable to get local issuer certificate Error you just need to Install Certificates.command. Just follow this step In macOS just open Macintosh HD Now Select Application Then Select Python folder ( Python3.6, Python3.7 Whatever You are using just select this folder ) Then, double click on Install Certificates.command. Now your error should be solved.
Solution 1: Install Certificates.command.
To solve this error you just need to Install Certificates.command. Just follow this step.
- In macOS just open Macintosh HD
- Now Select Application
- Then Select Python folder ( Python3.6, Python3.7 Whatever You are using just select this folder )
- Then, double click on Install Certificates.command.
- Now your error should be solved.

Solution 2: use unverified
If You are not looking for verified SSL then just use unverified SSL. just add these two line in your code.
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
Solution 3: Use this code
Just Use this code. This worked in all OS:
import ssl
import certifi
urlopen(request, context=ssl.create_default_context(cafile=certifi.where()))
Solution 4: install with pip
Simply install the certificates with pip.
pip install certifi
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read