Python SSL: Solution to CERTIFICATE_VERIFY_FAILED Error
Python SSL: Solution to CERTIFICATE_VERIFY_FAILED Error
Hello everyone, in this post I will talk about the solution to the "SSL: CERTIFICATE_VERIFY_FAILED" error received in Python. I got this error using "pytube" on Mac OS.
In fact, I can say that the vast majority encounters this error when using Python on Mac.
The full error I received looks like this.
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>
Why Do I Encounter the SSL: CERTIFICATE_VERIFY_FAILED Error?
The reason for this error is that Mac OS has more security measures compared to other operating systems, and when you want to download anything to the system, you must first grant access to the file or ensure it comes from a secure connection.
Solution to the SSL: CERTIFICATE_VERIFY_FAILED Error
The solution is quite simple, you could deal with granting permissions to each file individually and such, but instead you can simply add the following codes to your project.
import ssl # We include the ssl library to our project to solve the error. ssl._create_default_https_context = ssl._create_stdlib_context # Here, we completely fix the error by telling the system that the incoming connections are secure.
Yes friends, most likely the above code will help you solve the error. If you still continue to get the error, you can reach me below by leaving a comment.

Yorum Gönder